Skip to content

Conversation

@philprime
Copy link
Member

Fix Docker Multi-Registry Deployment

This PR resolves issues with Docker multi-registry multi-arch builds that were failing in the release workflow.

Problem

The Docker build workflow was failing with errors when attempting to push images by digest to multiple registries simultaneously:

ERROR: failed to push docker.io/techprimate/github-actions-utils-cli:latest by digest

Root Cause

Docker BuildKit's push-by-digest=true mode works with a single canonical registry. Attempting to push the same digest to multiple registries at once is not supported because:

  1. Each registry maintains its own blob storage
  2. Digests are registry-specific references
  3. A single build can only push by digest to one location

Solution

Implemented the recommended approach for multi-registry multi-arch builds:

Build Step (Per Platform)

  • ✅ Build platform-specific image (amd64 or arm64)
  • ✅ Push by digest to GHCR only (primary registry)
  • ✅ Export digest for merge step
  • ⚡ Runs in parallel for each platform

Merge Step (Single Job)

  • ✅ Download all platform digests
  • ✅ Reference GHCR digests to create multi-arch manifest
  • ✅ Apply tags for both GHCR and Docker Hub in one command
  • ✅ BuildKit automatically copies layers to Docker Hub

Changes

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

  • Removed docker.io from digest-based push (build step now pushes only to GHCR)
  • Simplified build step by removing conflicting metadata-action usage
  • Updated merge step to reference GHCR digests and tag both registries
  • Kept OCI-compliant labels for proper image metadata

.github/workflows/release.yml

  • Added fix-release branch to triggers for testing (can be removed after merge)

Testing

✅ Successfully tested on fix-release branch: https://github.com/techprimate/github-actions-utils-cli/actions/runs/19237095622

Results:

  • ✅ Multi-arch builds completed (linux/amd64, linux/arm64)
  • ✅ Images published to GHCR
  • ✅ Images published to Docker Hub
  • ✅ Manifest list created successfully
  • ✅ Latest tag applied to both registries

Docker Images

After this PR, images will be available at:

  • 📦 GHCR: ghcr.io/techprimate/github-actions-utils-cli:latest
  • 🐳 Docker Hub: docker.io/techprimate/github-actions-utils-cli:latest

Both support:

  • linux/amd64
  • linux/arm64

Verification

Pull and test the images:

# From GHCR
docker pull ghcr.io/techprimate/github-actions-utils-cli:latest
docker run --rm ghcr.io/techprimate/github-actions-utils-cli:latest --version

# From Docker Hub
docker pull docker.io/techprimate/github-actions-utils-cli:latest
docker run --rm docker.io/techprimate/github-actions-utils-cli:latest --version

Follow-Up

After merging, optionally remove the fix-release branch trigger from release.yml if no longer needed for testing.

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.
@philprime philprime merged commit ce8b26d into main Nov 10, 2025
28 checks passed
@philprime philprime deleted the fix-release branch November 10, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants