summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrazyMax <crazy-max@users.noreply.github.com>2022-09-08 16:13:41 +0200
committerCrazyMax <crazy-max@users.noreply.github.com>2022-11-17 20:57:12 +0100
commit25dc760162e1f6715fd97d23a3b24a32a31e424e (patch)
tree426016e0da28581cbfa64ef5916bef1c393343c1
parentd806d0760df0ae09109343fd52d3f3cf3986853e (diff)
downloaddocker-25dc760162e1f6715fd97d23a3b24a32a31e424e.tar.gz
Dockerfile: variant support in frozen-images stage
using TARGETVARIANT in frozen-images stage implies changes in `download-frozen-image-v2.sh` script to add support for variants so we are able to build against more platforms. Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
-rw-r--r--Dockerfile5
-rwxr-xr-xcontrib/download-frozen-image-v2.sh10
2 files changed, 12 insertions, 3 deletions
diff --git a/Dockerfile b/Dockerfile
index f4e7ea825d..299159a697 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -74,6 +74,9 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
&& git checkout -q "$GO_SWAGGER_COMMIT" \
&& go build -o /build/swagger github.com/go-swagger/go-swagger/cmd/swagger
+# frozen-images
+# See also frozenImages in "testutil/environment/protect.go" (which needs to
+# be updated when adding images to this list)
FROM debian:${BASE_DEBIAN_DISTRO} AS frozen-images
ARG DEBIAN_FRONTEND
RUN --mount=type=cache,sharing=locked,id=moby-frozen-images-aptlib,target=/var/lib/apt \
@@ -85,13 +88,13 @@ RUN --mount=type=cache,sharing=locked,id=moby-frozen-images-aptlib,target=/var/l
# Get useful and necessary Hub images so we can "docker load" locally instead of pulling
COPY contrib/download-frozen-image-v2.sh /
ARG TARGETARCH
+ARG TARGETVARIANT
RUN /download-frozen-image-v2.sh /build \
busybox:latest@sha256:95cf004f559831017cdf4628aaf1bb30133677be8702a8c5f2994629f637a209 \
busybox:glibc@sha256:1f81263701cddf6402afe9f33fca0266d9fff379e59b1748f33d3072da71ee85 \
debian:bullseye-slim@sha256:dacf278785a4daa9de07596ec739dbc07131e189942772210709c5c0777e8437 \
hello-world:latest@sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9 \
arm32v7/hello-world:latest@sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1
-# See also frozenImages in "testutil/environment/protect.go" (which needs to be updated when adding images to this list)
FROM base AS cross-false
diff --git a/contrib/download-frozen-image-v2.sh b/contrib/download-frozen-image-v2.sh
index b5e05b181a..e50f5ebdcc 100755
--- a/contrib/download-frozen-image-v2.sh
+++ b/contrib/download-frozen-image-v2.sh
@@ -261,6 +261,10 @@ get_target_arch() {
echo amd64
}
+get_target_variant() {
+ echo "${TARGETVARIANT:-}"
+}
+
while [ $# -gt 0 ]; do
imageTag="$1"
shift
@@ -311,11 +315,13 @@ while [ $# -gt 0 ]; do
found=""
targetArch="$(get_target_arch)"
+ targetVariant="$(get_target_variant)"
# parse first level multi-arch manifest
for i in "${!layers[@]}"; do
layerMeta="${layers[$i]}"
maniArch="$(echo "$layerMeta" | jq --raw-output '.platform.architecture')"
- if [ "$maniArch" = "${targetArch}" ]; then
+ maniVariant="$(echo "$layerMeta" | jq --raw-output '.platform.variant')"
+ if [[ "$maniArch" = "${targetArch}" ]] && [[ -z "${targetVariant}" || "$maniVariant" = "${targetVariant}" ]]; then
digest="$(echo "$layerMeta" | jq --raw-output '.digest')"
# get second level single manifest
submanifestJson="$(
@@ -332,7 +338,7 @@ while [ $# -gt 0 ]; do
fi
done
if [ -z "$found" ]; then
- echo >&2 "error: manifest for $maniArch is not found"
+ echo >&2 "error: manifest for ${targetArch}${targetVariant:+/${targetVariant}} is not found"
exit 1
fi
;;