Skip to content

Instantly share code, notes, and snippets.

@epomatti
Created April 26, 2023 15:23
Show Gist options
  • Save epomatti/e8f2892c87388e7d225f11429f190453 to your computer and use it in GitHub Desktop.
Save epomatti/e8f2892c87388e7d225f11429f190453 to your computer and use it in GitHub Desktop.
Go remote debug
# Commands
# docker build --tag godebug .
# docker run --security-opt="seccomp=unconfined" --cap-add=SYS_PTRACE -p:5001:5000 -p:2345:2345 godebug
FROM golang:1.19.2
WORKDIR /usr/src/app
COPY go.mod go.* ./
RUN go mod download && go mod verify
RUN go install github.com/go-delve/delve/cmd/dlv@latest
COPY . .
RUN go build -gcflags="all=-N -l" -v -o /usr/local/bin/app ./...
EXPOSE 2345
EXPOSE 5001
CMD ["dlv","debug","--listen=:2345","--headless=true","--api-version=2","--accept-multiclient"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment