diff --git a/Dockerfile b/Dockerfile index a89e34d90d..70c4f0395a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -182,26 +182,38 @@ RUN --mount=type=cache,sharing=locked,id=moby-cross-true-aptlib,target=/var/lib/ FROM runtime-dev-cross-${CROSS} AS runtime-dev -FROM base AS delve +# delve +FROM base AS delve-src +WORKDIR /usr/src/delve +RUN git init . && git remote add origin "https://github.com/go-delve/delve.git" # DELVE_VERSION specifies the version of the Delve debugger binary # from the https://github.com/go-delve/delve repository. # It can be used to run Docker with a possibility of # attaching debugger to it. -# ARG DELVE_VERSION=v1.8.1 -# Delve on Linux is currently only supported on amd64 and arm64; +RUN git fetch -q --depth 1 origin "${DELVE_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD + +FROM base AS delve-build +WORKDIR /usr/src/delve +ARG TARGETPLATFORM +RUN --mount=from=delve-src,src=/usr/src/delve,rw \ + --mount=type=cache,target=/root/.cache/go-build,id=delve-build-$TARGETPLATFORM \ + --mount=type=cache,target=/go/pkg/mod <