Skip to content

Build multi-platform images that build on each other #1298

Open
@nwalters512

Description

Description

Scenario

I'm trying to use this action to build, for multiple platforms, a pair of images, e.g. foo-base and foo-specialized. foo-specialized uses foo-base as a base image, e.g.:

FROM foo-base:latest
# ...

I'd like to perform builds on both PRs and on my main branch:

  • On PRs, I'll push a tag based on the Git SHA
  • On the main branch, I'll push both the latest tag and a tag based on the Git SHA

Attempt

My initial attempt was just this:

      - name: Build and push foo-base
        uses: docker/build-push-action@v6
        with:
          context: path/to/base
          platforms: linux/amd64,linux/arm64
          push: true
          no-cache: true
          tags: foo-base:${{ github.event.pull_request.head.sha || github.sha }}

      - name: Build and push foo-specialized
        uses: docker/build-push-action@v6
        with:
          context: path/to/specialized
          platforms: linux/amd64,linux/arm64
          push: true
          no-cache: true
          tags: foo-specialized:${{ github.event.pull_request.head.sha || github.sha }}

However, this didn't work as there wasn't a latest tag for foo-base. So I tried changing things to load the image back into Docker and tag it as latest (I can't specify ...:latest in tags: because I don't want the latest tag pushed to Docker Hub for PR branches):

      - name: Build and push foo-base
        uses: docker/build-push-action@v6
        with:
          context: path/to/base
          platforms: linux/amd64,linux/arm64
          push: true
          load: true
          no-cache: true
          tags: foo-base:${{ github.event.pull_request.head.sha || github.sha }}

      - name: Tag foo-base as latest
        run: docker tag foo-base:${{ github.event.pull_request.head.sha || github.sha }} foo-base:latest

      - name: Build and push foo-specialized
        uses: docker/build-push-action@v6
        with:
          context: path/to/specialized
          platforms: linux/amd64,linux/arm64
          push: true
          no-cache: true
          tags: foo-specialized:${{ github.event.pull_request.head.sha || github.sha }}

However, that fails because of docker/buildx#59. The recommended solution for that was to use the containerd image store, but I don't see any documentation in this action about how to set that up or use it for image loading/exporting.

Question

Can you recommend any way to achieve what I want? It seems like using the containerd image store would be the way to go, but as I mentioned above, there's no documentation on this action about how to use it. Do you have any advice? Let me know if this is better suited to be a discussion, or if I should turn this into a concrete feature request, e.g. "let me configure this action to use containerd as the image store".

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions