Skip to content

Commit fe1583a

Browse files
committed
dockerfile: add delve to binaries-for-test
Signed-off-by: CrazyMax <[email protected]>
1 parent 952ac2a commit fe1583a

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

Dockerfile

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@ FROM golatest AS gobuild-base
3737
RUN apk add --no-cache file bash clang lld musl-dev pkgconfig git make
3838
COPY --link --from=xx / /
3939

40-
# dlv builds delve for debug variant images
41-
FROM gobuild-base AS dlv
42-
ARG DELVE_VERSION
43-
RUN --mount=target=/root/.cache,type=cache \
44-
--mount=target=/go/pkg/mod,type=cache \
45-
GOBIN=/usr/bin go install github.com/go-delve/delve/cmd/dlv@${DELVE_VERSION}
46-
4740
# runc builds runc binary
4841
FROM gobuild-base AS runc
4942
WORKDIR $GOPATH/src/github.com/opencontainers/runc
@@ -337,6 +330,27 @@ rmdir "$coverdir/helpers"
337330
exit $ecode
338331
EOF
339332

333+
# dlv builds delve for debug variant images
334+
FROM gobuild-base AS dlv
335+
ARG DELVE_VERSION
336+
ARG TARGETPLATFORM
337+
RUN --mount=target=/root/.cache,type=cache\
338+
--mount=target=/go/pkg/mod,type=cache <<EOT
339+
set -ex
340+
mkdir /out
341+
if [ "$(xx-info os)" = "freebsd" ]; then
342+
echo "WARN: dlv requires cgo enabled on FreeBSD, skipping: https://github.com/moby/buildkit/pull/5497#issuecomment-2462031339"
343+
exit 0
344+
fi
345+
xx-go install "github.com/go-delve/delve/cmd/dlv@${DELVE_VERSION}"
346+
if ! xx-info is-cross; then
347+
/go/bin/dlv version
348+
mv /go/bin/dlv /out
349+
else
350+
mv /go/bin/*/dlv* /out
351+
fi
352+
EOT
353+
340354
FROM buildkit-export AS buildkit-linux
341355
COPY --link --from=binaries / /usr/bin/
342356
ENV BUILDKIT_SETUP_CGROUPV2_ROOT=1
@@ -366,6 +380,7 @@ FROM binaries AS buildkit-windows
366380

367381
FROM scratch AS binaries-for-test
368382
COPY --link --from=gotestsum /out /
383+
COPY --link --from=dlv /out /
369384
COPY --link --from=registry /out /
370385
COPY --link --from=containerd /out /
371386
COPY --link --from=binaries / /

0 commit comments

Comments
 (0)