From b0bcdacc7d61141a57b37731644d96a595684925 Mon Sep 17 00:00:00 2001 From: Thomas E Lackey Date: Wed, 25 Jan 2023 16:10:29 -0600 Subject: [PATCH] Add debugging support for Docker container. (#228) --- Dockerfile | 6 ++++++ entrypoint.sh | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e4bc84eb..78502d6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,9 @@ RUN apk --update --no-cache add make git g++ linux-headers # DEBUG RUN apk add busybox-extras +# Include dlv +RUN go install github.com/go-delve/delve/cmd/dlv@latest + # Build ipld-eth-server WORKDIR /go/src/github.com/cerc-io/ipld-eth-server @@ -46,4 +49,7 @@ COPY --from=builder /go/src/github.com/cerc-io/ipld-eth-server/ipld-eth-server i COPY --from=builder /goose goose COPY --from=builder /go/src/github.com/cerc-io/ipld-eth-server/environments environments +# Allow for debugging +COPY --from=builder /go/bin/dlv /usr/local/bin/ + ENTRYPOINT ["/app/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 3e0e2372..109736c4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,8 +2,13 @@ echo "Beginning the ipld-eth-server process" -echo running: ./ipld-eth-server ${VDB_COMMAND} --config=config.toml -./ipld-eth-server ${VDB_COMMAND} --config=config.toml +START_CMD="./ipld-eth-server" +if [ "true" == "$CERC_REMOTE_DEBUG" ] && [ -x "/usr/local/bin/dlv" ]; then + START_CMD="/usr/local/bin/dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec `pwd`/ipld-eth-server --continue --" +fi + +echo running: $START_CMD ${VDB_COMMAND} --config=`pwd`/config.toml +$START_CMD ${VDB_COMMAND} --config=`pwd`/config.toml rv=$? if [ $rv != 0 ]; then