docker / docker/bake-action

Single target images are generated as manifest lists

Open
#322 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status/triage
Dominant language
TypeScript
Stars
301
Forks
43
Avg merge
2d 5h
Merged PRs (30d)
20

Description

Contributing guidelines
I've found a bug, and:
  • The documentation does not mention anything about my problem
  • There are no open or closed issues that are related to my problem
Description

Single arch images are generated with a manifest list, not allowing them to be merged later.

Expected behaviour

Single platform images built through bake-file should not contain a manifest list.

I know I can use emulation to build images on a single machine however the emulation process is not optimal usually taking much longer to complete. Trying to leverage specific runners (ie ARM) to build separate images and then merge the manifests. I have a way to do this however I am unable to merge the manifests as the images generated from the bake action are is a manifest list already.

Using build-push-action would work but this repo leverages a number of features from the bake file that I would like to keep.

Actual behaviour

Resulting images are full manufest lists even when single platform is built.

Repository URL

No response

Workflow run URL

No response

YAML workflow
My approach is as follows (let me know if there is a more optimal way of doing this)

bake-build-arm:
    name: bake-build-arm
    runs-on: arm-runner
    permissions:
      packages: write
      contents: read

    steps:
      # 2.1 - Generate Image Metadata
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5.7.0
        with:
          images: ghcr.io/${{ github.repository }}/${{ inputs.image }}
          tags: |
            type=raw,value=${{ inputs.tag }}
          flavor: |
            latest=false
            suffix=--arm64

      # 2.2 - Login against the docker registry
      - name: Login to registry GHCR
       ...

      # 2.3 - Setup Docker BuildX for multi platform building
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3.10.0

      # 2.4 - Build Docker Images
      - name: Build Images using BuildX Bake
        uses: docker/bake-action@v6.5.0
        with:
          files: |
            "docker-bake.hcl"
            cwd://${{ steps.meta.outputs.bake-file }}
          targets: ${{ inputs.image }}
          push: true
          set: |
            *.cache-from=type=gha,scope=build-${{ inputs.image }}
            *.cache-to=type=gha,scope=build-${{ inputs.image }},mode=max
            *.platform=linux/arm64

Same for the AMD version but generates a `--amd64` tag

Then in a later stage I try to merge the two using

docker manifest create ${{ inputs.name }} \
              --amend ${{ inputs.name }}--amd64 \
              --amend ${{ inputs.name }}--arm64

But it fails stating that `--amd64 is a manifest list` (same for arm64)

When I manually inspect them, indeed I see that it contains a manifest array. Is there a way to override that so that it builds the same single image as `build-push-action` does?
Workflow logs

Run docker manifest create ghcr.io/org-xyz/repo-123/image-abc:7.4.2 \
  docker manifest create ghcr.io/org-xyz/repo-123/image-abc:7.4.2 \
    --amend ghcr.io/org-xyz/repo-123/image-abc:7.4.2--amd64 \
    --amend ghcr.io/org-xyz/repo-123/image-abc:7.4.2--arm64
  docker manifest annotate --arch amd64 --os linux ghcr.io/org-xyz/repo-123/image-abc:7.4.2 ghcr.io/org-xyz/repo-123/image-abc:7.4.2--amd64
  docker manifest annotate --arch arm64 --os linux ghcr.io/org-xyz/repo-123/image-abc:7.4.2 ghcr.io/org-xyz/repo-123/image-abc:7.4.2--arm64
  shell: /usr/bin/bash -e {0}
ghcr.io/org-xyz/repo-123/image-abc:7.4.2--amd64 is a manifest list
Error: Process completed with exit code 1.
BuildKit logs

Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the workflow YAML, the docker-bake.hcl input, and the generated metadata bake file used by docker/bake-action v6.5.0. Reproduce the single-platform build and inspect its published image, then compare the result with the docker manifest create commands shown in the issue. Done means single-platform outputs can be amended into a multi-platform manifest without the manifest-list error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, github-actions
Domain
build-system, ci-cd, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.