From 19f3448c21346ad7c68f5788e38e3b5af255c934 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sat, 26 Nov 2022 16:41:16 +0100 Subject: [PATCH] Dockerfile: delve cross build with TARGETPLATFORM Signed-off-by: CrazyMax --- Dockerfile | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) 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 <