New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delve debugging? #45
Comments
Here is how i solved it right now. I appreciate any input, how others solve this! The delve debugger compiles and executes the application, exposes the http server under port Dockerfile FROM golang:1.18-alpine AS base
WORKDIR /app
FROM base AS development
RUN apk add build-base
# Create external debugger
RUN go install github.com/go-delve/delve/cmd/dlv@latest
# Restart server on code change
RUN go install github.com/cespare/reflex@latest
COPY reflex.conf /
ENTRYPOINT ["reflex", "-c", "/reflex.conf"] reflex.conf # Start delve debugger
-sr '(\.go$|go\.mod|\.tmpl$)' -- \
dlv debug --headless --listen=:12345 --accept-multiclient --continue docker-compose.yaml api:
build:
context: .
target: development
volumes:
- .:/app
ports:
- 30001:8080
- 30002:12345 .vscode/launch.json {
"version": "0.2.0",
"configurations": [
{
"name": "Attach to container",
"type": "go",
"request": "attach",
"mode": "remote",
"debugAdapter": "dlv-dap",
"port": 30002,
"substitutePath": [{ "from": "${workspaceFolder}", "to": "/app" }]
}
]
} |
I was wondering how to debug the go code in development?
Normaly i would use
delve
to set breakpoints in VSCode , but i'm not quite sure how to do this in adocker-compose
setup.Any insights would be appreciated.
The text was updated successfully, but these errors were encountered: