From 13872ace65931f411fe6116c9bccc4d2c7e5ef67 Mon Sep 17 00:00:00 2001 From: Matt McCormick Date: Wed, 24 Sep 2025 11:24:33 -0400 Subject: [PATCH] ci: push multi-arch images with manifest-tool Instead of buildah. - Simplified workflow: manifest-tool provides a more straightforward command-line interface for creating manifest lists - Better integration: manifest-tool is specifically designed for manifest list/OCI index creation and management - Cross-platform compatibility: Works with both Docker v2.2 manifest lists and OCI v1 indexes - Template-based approach: The --template and --platforms flags provide a cleaner way to specify multi-arch images --- .github/workflows/main.yml | 7 +++++++ Makefile | 17 +++++++++-------- README.md | 8 ++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 26907c6..ced1388 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1547,6 +1547,13 @@ jobs: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASS }} + - name: Install manifest-tool + if: github.ref == 'refs/heads/master' + run: | + wget https://github.com/estesp/manifest-tool/releases/latest/download/binaries-manifest-tool.tar.gz -O - | tar -xz + sudo cp manifest-tool-linux-amd64 /usr/local/bin/manifest-tool + sudo chmod +x /usr/local/bin/manifest-tool + - name: deploy-multi-arch if: github.ref == 'refs/heads/master' run: | diff --git a/Makefile b/Makefile index 1d310f0..a269bad 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ # Common values: docker, podman, buildah DOCKER := $(or $(OCI_EXE), docker) BUILD_DOCKER := $(or $(BUILD_DOCKER), $(DOCKER)) -BUILDAH := $(or $(BUILDAH_EXE), buildah) +MANIFEST_TOOL := $(or $(MANIFEST_TOOL_EXE), manifest-tool) RM = --rm # Name of the docker-equivalent executable for running test containers. @@ -382,16 +382,17 @@ $(addsuffix .push,$(STANDARD_IMAGES) $(NON_STANDARD_IMAGES)): $$(basename $$@) .SECONDEXPANSION: $(addsuffix .manifest,$(MULTIARCH_IMAGES) web-wasi-threads web-wasm): $$(basename $$@) - if $(BUILDAH) manifest exists $(ORG)/$(basename $@); then \ - $(BUILDAH) manifest rm $(ORG)/$(basename $@); fi - $(BUILDAH) manifest create $(ORG)/$(basename $@) - $(BUILDAH) manifest add $(ORG)/$(basename $@) docker://$(ORG)/$(basename $@):latest-amd64 - $(BUILDAH) manifest add $(ORG)/$(basename $@) docker://$(ORG)/$(basename $@):latest-arm64 + $(MANIFEST_TOOL) push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template $(ORG)/$(basename $@):latest-ARCH \ + --target $(ORG)/$(basename $@):latest .SECONDEXPANSION: $(addsuffix .push,$(MULTIARCH_IMAGES) web-wasi-threads web-wasm): $$(basename $$@).manifest - $(BUILDAH) manifest push --all --format v2s2 $(ORG)/$(basename $@) docker://$(ORG)/$(basename $@):latest - $(BUILDAH) manifest push --all --format v2s2 $(ORG)/$(basename $@) docker://$(ORG)/$(basename $@):$(TAG) + $(MANIFEST_TOOL) push from-args \ + --platforms linux/amd64,linux/arm64 \ + --template $(ORG)/$(basename $@):$(TAG)-ARCH \ + --target $(ORG)/$(basename $@):$(TAG) # # testing prerequisites implicit rule diff --git a/README.md b/README.md index 6322579..ec520a0 100644 --- a/README.md +++ b/README.md @@ -620,6 +620,14 @@ Note that the architecture is now `aarch64` instead of `amd64`, so it runs nativ \-\-- +## Multi-architecture Image Creation + +For creating multi-architecture container images, this project uses [manifest-tool](https://github.com/estesp/manifest-tool) to create and manage manifest lists that combine platform-specific images into a single multi-platform reference. This allows container runtimes to automatically select the appropriate image based on the target architecture. + +The multi-architecture images are built on different architectures (amd64 and arm64) and then combined using manifest-tool's `push from-args` command, which creates manifest lists pointing to the individual platform-specific images. + +--- + Credits: - [sdt/docker-raspberry-pi-cross-compiler](https://github.com/sdt/docker-raspberry-pi-cross-compiler), who invented the base of the **dockcross** script.