Skip to content

Commit 43397db

Browse files
committed
fix: resolve Docker multi-registry deployment issues
Fix digest-based multi-arch builds for dual registry publishing (GHCR and Docker Hub). The issue was attempting to push images by digest to multiple registries simultaneously, which isn't supported. Docker BuildKit's push-by-digest mode works with a single canonical registry. Solution: - Push platform-specific images by digest to GHCR (primary registry) - In merge step, create multi-arch manifest referencing GHCR digests - Apply tags for both GHCR and Docker Hub in single imagetools command - BuildKit automatically handles copying layers to Docker Hub Changes: - Simplified build step to push only to GHCR with push-by-digest - Updated merge step to reference GHCR digests and tag both registries - Removed conflicting docker/metadata-action usage from build step - Kept OCI-compliant labels for image metadata This follows the recommended approach for multi-registry multi-arch builds as documented in Docker BuildKit best practices.
1 parent fede0f9 commit 43397db

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

.github/workflows/build-cli-docker.yml

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
maintainer=techprimate GmbH <opensource@techprimate.com>
8181
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache-${{ matrix.platform.tag }}
8282
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache-${{ matrix.platform.tag }},mode=max
83-
outputs: type=image,name=docker.io/${{ github.repository }},name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
83+
outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
8484

8585
- name: Export digest
8686
if: github.event_name != 'pull_request'
@@ -157,32 +157,20 @@ jobs:
157157
- name: Create manifest list and push
158158
working-directory: /tmp/digests
159159
run: |
160-
# Extract all tags
161-
image_tags=$(printf '%s' "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr '.tags | map("-t " + .) | join(" ")')
162-
echo "Creating manifest list with tags: $image_tags"
163-
164-
# We need to create separate manifests for each registry
165-
# because the digests are registry-specific
166-
167-
# For each registry, create manifest with its digests
168-
for registry in "docker.io/${{ github.repository }}" "ghcr.io/${{ github.repository }}"; do
169-
echo "Processing registry: $registry"
170-
171-
# Get tags for this registry
172-
registry_tags=$(printf '%s' "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr --arg registry "$registry" '.tags | map(select(startswith($registry))) | map("-t " + .) | join(" ")')
173-
174-
# Build digest references for this registry
175-
digest_refs=""
176-
for digest_file in *; do
177-
digest_refs="$digest_refs ${registry}@sha256:${digest_file}"
178-
done
160+
# Build digest references from GHCR (where images were pushed)
161+
digest_refs=""
162+
for digest_file in *; do
163+
digest_refs="$digest_refs ghcr.io/${{ github.repository }}@sha256:${digest_file}"
164+
done
165+
echo "Digest references: $digest_refs"
179166
180-
echo "Tags for $registry: $registry_tags"
181-
echo "Digest refs: $digest_refs"
167+
# Get all tags (both GHCR and Docker Hub)
168+
all_tags=$(printf '%s' "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr '.tags | map("-t " + .) | join(" ")')
169+
echo "Creating manifest list with tags: $all_tags"
182170
183-
# Create and push manifest for this registry
184-
docker buildx imagetools create $registry_tags $digest_refs
185-
done
171+
# Create manifest list with all tags (GHCR and Docker Hub)
172+
# This will create the manifest in GHCR and simultaneously tag/push to Docker Hub
173+
docker buildx imagetools create $all_tags $digest_refs
186174
187175
# Inspect the first tag for verification
188176
first_tag=$(printf '%s' "$DOCKER_METADATA_OUTPUT_JSON" | jq -cr '.tags[0]')

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- "v*.*.*"
77
branches:
88
- main
9+
- fix-release
910
pull_request:
1011
workflow_dispatch:
1112

0 commit comments

Comments
 (0)