Delve debugging with hot reload

Viewed 865

My current development setup is a docker file that compiles the code on every save with CompileDaemon, and debug with Delve.

Currently I get almost everything to work. The only problem is that the port is already in use when I try to start the debug again.

Is their a better way to accomplish live reload with debug inside a docker container?

Dockerfile:

FROM golang:latest

RUN go get github.com/githubnemo/CompileDaemon && \
  go get github.com/go-delve/delve/cmd/dlv  
WORKDIR /app
COPY go.* ./
RUN go mod download

COPY ./ ./

EXPOSE 5000 2345
# echo 1 is to block build command 
ENTRYPOINT CompileDaemon --build="echo 1" --command="dlv debug --headless --listen=:2345 --api-version=2 --accept-multiclient cmd/app/main.go"
0 Answers
Related