Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
nwalters512 opened this issue Jan 8, 2025 · 0 comments
Open

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

nwalters512 opened this issue Jan 8, 2025 · 0 comments
Labels
kind/enhancement New feature or request status/triage

Comments

@nwalters512
Copy link

nwalters512 commented Jan 8, 2025

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request status/triage
Projects
None yet
Development

No branches or pull requests

1 participant