Skip to content

Commit 2e884d1

Browse files
committed
fix(docker): make latest tag a multi-arch manifest
Disable latest=auto on both amd64 and arm64 builds to prevent a race where the last one to finish wins the bare latest tag. Instead, push architecture-specific latest-{arch}-debian tags explicitly, then create both latest-debian and bare latest as multi-arch manifests in the combine-manifests job.
1 parent 752b2e6 commit 2e884d1

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

.github/workflows/osrm-backend-docker.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ jobs:
3434
uses: docker/metadata-action@v6
3535
with:
3636
images: ghcr.io/${{ github.repository }}
37+
flavor: |
38+
latest=false
3739
tags: |
40+
type=raw,value=latest,suffix=-amd64-${{ matrix.docker-base-image }}
3841
type=semver,pattern=v{{version}},value=${{ env.SEMVER_REF }},suffix=-amd64-${{ matrix.docker-base-image }}
3942
type=semver,pattern={{version}},value=${{ env.SEMVER_REF }},suffix=-amd64-${{ matrix.docker-base-image }}
4043
type=semver,pattern={{major}}.{{minor}},value=${{ env.SEMVER_REF }},suffix=-amd64-${{ matrix.docker-base-image }}
@@ -132,7 +135,10 @@ jobs:
132135
uses: docker/metadata-action@v6
133136
with:
134137
images: ghcr.io/${{ github.repository }}
138+
flavor: |
139+
latest=false
135140
tags: |
141+
type=raw,value=latest,suffix=-arm64-${{ matrix.docker-base-image }}
136142
type=semver,pattern=v{{version}},value=${{ env.SEMVER_REF }},suffix=-arm64-${{ matrix.docker-base-image }}
137143
type=semver,pattern={{version}},value=${{ env.SEMVER_REF }},suffix=-arm64-${{ matrix.docker-base-image }}
138144
type=semver,pattern={{major}}.{{minor}},value=${{ env.SEMVER_REF }},suffix=-arm64-${{ matrix.docker-base-image }}
@@ -260,7 +266,11 @@ jobs:
260266
MAJOR_MINOR="${VERSION%.*}"
261267
TAGS+=("$VERSION" "$MAJOR_MINOR")
262268
fi
263-
269+
270+
# Always include latest so the multi-arch manifest serves as the
271+
# default image for docker pull without an explicit version tag.
272+
TAGS+=("latest")
273+
264274
# Deduplicate tags while preserving order
265275
MANIFEST_TAGS=()
266276
declare -A SEEN_TAGS=()
@@ -275,8 +285,21 @@ jobs:
275285
276286
for IMAGE_SUFFIX in "" "-debug" "-assertions"; do
277287
for TAG in "${MANIFEST_TAGS[@]}"; do
288+
# The "latest" tag only applies to the base image, not to
289+
# -debug or -assertions variant suffixes.
290+
if [ "$TAG" = "latest" ] && [ -n "$IMAGE_SUFFIX" ]; then
291+
continue
292+
fi
278293
docker buildx imagetools create -t "$REGISTRY:${TAG}${IMAGE_SUFFIX}-${{ matrix.docker-base-image }}" \
279294
"$REGISTRY:${TAG}${IMAGE_SUFFIX}-amd64-${{ matrix.docker-base-image }}" \
280295
"$REGISTRY:${TAG}${IMAGE_SUFFIX}-arm64-${{ matrix.docker-base-image }}"
296+
297+
# Additionally create a bare "latest" multi-arch manifest (no
298+
# -debian suffix) so that "docker pull …:latest" works as expected.
299+
if [ "$TAG" = "latest" ] && [ -z "$IMAGE_SUFFIX" ]; then
300+
docker buildx imagetools create -t "$REGISTRY:latest" \
301+
"$REGISTRY:latest-amd64-${{ matrix.docker-base-image }}" \
302+
"$REGISTRY:latest-arm64-${{ matrix.docker-base-image }}"
303+
fi
281304
done
282305
done

0 commit comments

Comments
 (0)