Skip to content

Commit 13a1efb

Browse files
authored
Merge pull request moby#5497 from crazy-max/delve-windows
dockerfile: add delve to binaries-for-test
2 parents 2d013b6 + fe1583a commit 13a1efb

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
@@ -39,13 +39,6 @@ FROM golatest AS gobuild-base
3939
RUN apk add --no-cache file bash clang lld musl-dev pkgconfig git make
4040
COPY --link --from=xx / /
4141

42-
# dlv builds delve for debug variant images
43-
FROM gobuild-base AS dlv
44-
ARG DELVE_VERSION
45-
RUN --mount=target=/root/.cache,type=cache \
46-
--mount=target=/go/pkg/mod,type=cache \
47-
GOBIN=/usr/bin go install github.com/go-delve/delve/cmd/dlv@${DELVE_VERSION}
48-
4942
# runc builds runc binary
5043
FROM gobuild-base AS runc
5144
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)