Merge pull request #47595 from tonistiigi/dockerfile-dlv-update

Dockerfile: avoid hardcoding arch combinations for delve
This commit is contained in:
Sebastiaan van Stijn 2024-03-21 15:46:47 +01:00 committed by GitHub
commit 1552e30a05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1.7
ARG GO_VERSION=1.21.8 ARG GO_VERSION=1.21.8
ARG BASE_DEBIAN_DISTRO="bookworm" ARG BASE_DEBIAN_DISTRO="bookworm"
@ -24,6 +24,12 @@ ARG DOCKER_STATIC=1
# specified here should match a current release. # specified here should match a current release.
ARG REGISTRY_VERSION=2.8.3 ARG REGISTRY_VERSION=2.8.3
# delve is currently only supported on linux/amd64 and linux/arm64;
# https://github.com/go-delve/delve/blob/v1.8.1/pkg/proc/native/support_sentinel.go#L1-L6
ARG DELVE_SUPPORTED=${TARGETPLATFORM#linux/amd64} DELVE_SUPPORTED=${DELVE_SUPPORTED#linux/arm64}
ARG DELVE_SUPPORTED=${DELVE_SUPPORTED:+"unsupported"}
ARG DELVE_SUPPORTED=${DELVE_SUPPORTED:-"supported"}
# cross compilation helper # cross compilation helper
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
@ -144,7 +150,7 @@ RUN git init . && git remote add origin "https://github.com/go-delve/delve.git"
ARG DELVE_VERSION=v1.21.1 ARG DELVE_VERSION=v1.21.1
RUN git fetch -q --depth 1 origin "${DELVE_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD RUN git fetch -q --depth 1 origin "${DELVE_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD
FROM base AS delve-build FROM base AS delve-supported
WORKDIR /usr/src/delve WORKDIR /usr/src/delve
ARG TARGETPLATFORM ARG TARGETPLATFORM
RUN --mount=from=delve-src,src=/usr/src/delve,rw \ RUN --mount=from=delve-src,src=/usr/src/delve,rw \
@ -155,16 +161,8 @@ RUN --mount=from=delve-src,src=/usr/src/delve,rw \
xx-verify /build/dlv xx-verify /build/dlv
EOT EOT
# delve is currently only supported on linux/amd64 and linux/arm64; FROM binary-dummy AS delve-unsupported
# https://github.com/go-delve/delve/blob/v1.8.1/pkg/proc/native/support_sentinel.go#L1-L6 FROM delve-${DELVE_SUPPORTED} AS delve
FROM binary-dummy AS delve-windows
FROM binary-dummy AS delve-linux-arm
FROM binary-dummy AS delve-linux-ppc64le
FROM binary-dummy AS delve-linux-s390x
FROM delve-build AS delve-linux-amd64
FROM delve-build AS delve-linux-arm64
FROM delve-linux-${TARGETARCH} AS delve-linux
FROM delve-${TARGETOS} AS delve
FROM base AS tomll FROM base AS tomll
# GOTOML_VERSION specifies the version of the tomll binary to build and install # GOTOML_VERSION specifies the version of the tomll binary to build and install