Skip to content

Commit 83fbbc3

Browse files
committed
Fix docker pull and --build-context to reference correct arch-specific parent manifest
This avoids trusting Docker and BuildKit to select the "correct" base image (ie, the one we're referencing in our annotations).
1 parent c6af5a9 commit 83fbbc3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.test/meta-commands/out.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SOURCE_DATE_EPOCH=1700741054 \
3535
--tag 'amd64/docker:24.0.7-cli-alpine3.18' \
3636
--tag 'oisupport/staging-amd64:4b199ac326c74b3058a147e14f553af9e8e1659abc29bd3e82c9c9807b66ee43' \
3737
--platform 'linux/amd64' \
38-
--build-context 'alpine:3.18=docker-image://alpine@sha256:34871e7290500828b39e22294660bee86d966bc0017544e848dd9a255cdf59e0' \
38+
--build-context 'alpine:3.18=docker-image://alpine@sha256:d695c3de6fcd8cfe3a6222b0358425d40adfd129a8a47c3416faff1a8aece389' \
3939
--build-arg BUILDKIT_SYNTAX="$BASHBREW_BUILDKIT_SYNTAX" \
4040
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=all \
4141
--file 'Dockerfile' \
@@ -61,8 +61,8 @@ rm -rf temp
6161

6262
# docker:24.0.7-windowsservercore-ltsc2022 [windows-amd64]
6363
# <pull>
64-
docker pull 'mcr.microsoft.com/windows/servercore@sha256:308ef3f8ee3e9c9a1bdec460009c1e6394b329db13eb3149461f8841be5b538a'
65-
docker tag 'mcr.microsoft.com/windows/servercore@sha256:308ef3f8ee3e9c9a1bdec460009c1e6394b329db13eb3149461f8841be5b538a' 'mcr.microsoft.com/windows/servercore:ltsc2022'
64+
docker pull 'mcr.microsoft.com/windows/servercore@sha256:d4ab2dd7d3d0fce6edc5df459565a4c96bbb1d0148065b215ab5ddcab1e42eb4'
65+
docker tag 'mcr.microsoft.com/windows/servercore@sha256:d4ab2dd7d3d0fce6edc5df459565a4c96bbb1d0148065b215ab5ddcab1e42eb4' 'mcr.microsoft.com/windows/servercore:ltsc2022'
6666
# </pull>
6767
# <build>
6868
SOURCE_DATE_EPOCH=1700741054 \

meta.jq

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def pull_command:
3636
.build.resolvedParents
3737
| to_entries[]
3838
| (
39-
.value.annotations["org.opencontainers.image.ref.name"] // error("parent \(.key) missing ref")
39+
.value.manifests[0].annotations["org.opencontainers.image.ref.name"]
40+
// .value.annotations["org.opencontainers.image.ref.name"]
41+
// error("parent \(.key) missing ref")
4042
| normalize_ref_to_docker
4143
) as $ref
4244
| @sh "docker pull \($ref)",
@@ -191,7 +193,9 @@ def build_command:
191193
.build.resolvedParents
192194
| to_entries[]
193195
| .key + "=docker-image://" + (
194-
.value.annotations["org.opencontainers.image.ref.name"] // error("parent \(.key) missing ref")
196+
.value.manifests[0].annotations["org.opencontainers.image.ref.name"]
197+
// .value.annotations["org.opencontainers.image.ref.name"]
198+
// error("parent \(.key) missing ref")
195199
| normalize_ref_to_docker
196200
)
197201
| "--build-context " + @sh

0 commit comments

Comments
 (0)