Skip to content

Commit

Permalink
dockerfile: add delve to binaries-for-test
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Nov 7, 2024
1 parent 952ac2a commit b9d503b
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ FROM golatest AS gobuild-base
RUN apk add --no-cache file bash clang lld musl-dev pkgconfig git make
COPY --link --from=xx / /

# dlv builds delve for debug variant images
FROM gobuild-base AS dlv
ARG DELVE_VERSION
RUN --mount=target=/root/.cache,type=cache \
--mount=target=/go/pkg/mod,type=cache \
GOBIN=/usr/bin go install github.com/go-delve/delve/cmd/dlv@${DELVE_VERSION}

# runc builds runc binary
FROM gobuild-base AS runc
WORKDIR $GOPATH/src/github.com/opencontainers/runc
Expand Down Expand Up @@ -337,6 +330,27 @@ rmdir "$coverdir/helpers"
exit $ecode
EOF

# dlv builds delve for debug variant images
FROM gobuild-base AS dlv
ARG DELVE_VERSION
ARG TARGETPLATFORM
RUN --mount=target=/root/.cache,type=cache\
--mount=target=/go/pkg/mod,type=cache <<EOT
set -ex
if [ "$(xx-info os)" = "freebsd" ]; then
echo "WARN: dlv requires cgo enabled on FreeBSD, skipping: https://github.com/moby/buildkit/pull/5497#issuecomment-2462031339"
exit 0
fi
xx-go install "github.com/go-delve/delve/cmd/dlv@${DELVE_VERSION}"
mkdir /out
if ! xx-info is-cross; then
/go/bin/dlv version
mv /go/bin/dlv /out
else
mv /go/bin/*/dlv* /out
fi
EOT

FROM buildkit-export AS buildkit-linux
COPY --link --from=binaries / /usr/bin/
ENV BUILDKIT_SETUP_CGROUPV2_ROOT=1
Expand Down Expand Up @@ -366,6 +380,7 @@ FROM binaries AS buildkit-windows

FROM scratch AS binaries-for-test
COPY --link --from=gotestsum /out /
COPY --link --from=dlv /out /
COPY --link --from=registry /out /
COPY --link --from=containerd /out /
COPY --link --from=binaries / /
Expand Down

0 comments on commit b9d503b

Please sign in to comment.