Suggestion to improve a dockerfile for using a VSCode debugger

There is a dockerfile sample Heroic Labs Documentation | Using VSCode Debugger where copying and building the go library ( is before installing the delve package. Maybe it will be better to change the order to install the delve package first? This change will prevent installing delve package every time we change our source files. In my environment rebuilding sources takes ~10 sec and installing delve takes ~30-60 sec, so this changes allowed me to save my time when debugging.
So I guess the dockerfile in the document would be:

FROM AS go-builder
WORKDIR /backend

RUN apt-get update && \
    apt-get -y upgrade && \
    apt-get install -y --no-install-recommends gcc libc6-dev

RUN go install

COPY go.mod .
COPY vendor/ vendor/
COPY *.go .

RUN go build --trimpath --gcflags "all=-N -l" --mod=vendor --buildmode=plugin -o ./


COPY --from=go-builder /go/bin/dlv /nakama
COPY --from=go-builder /backend/ /nakama/data/modules/
COPY local.yml /nakama/data/

Good catch, thanks for that @Andrey. We’ll update the docs to reflect the improvement.

1 Like