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

Not able to build multiple Dockerfiles to create a multi-arch image #2840

Open
alanraju-aot opened this issue Dec 4, 2024 · 2 comments
Open

Comments

@alanraju-aot
Copy link

We have a problem to build one of our containers that have two Dockerfiles. One is for normal amd64 and and another one used for arm64. So our condition is to build those two docker files using a Git action to build and push a multi-arch image that can both be used in mac and windows. I have tried some solutions like follows:

    • name: Build and Push Multi-Arch Image
      run: |
      docker buildx build
      --platform linux/amd64,linux/arm64
      --file Dockerfile --file Dockerfile-ARM64
      --tag repo-name/image-name:{tag}
      --push .
    • name: Build and push Docker image
      if: ${{ github.ref == 'refs/heads/master' }}
      uses: docker/build-push-action@v4
      with:
      context: container-name
      file: |
      container-name/Dockerfile
      container-name/Dockerfile-ARM64
      push: true
      platforms: linux/amd64,linux/arm64/v8
      tags: ${{ steps.meta.outputs.tags }}, repo-name/image-name:{tag}
      labels: ${{ steps.meta.outputs.labels }}

whenever we run the workflow I'm getting the error as :
`` Run docker buildx build
#0 building with "builder-7d387e50-81ba-4f37-b2a8-6b4d790c3f09" instance using docker-container driver

#1 [internal] load build definition from Dockerfile-ARM64
#1 transferring dockerfile: 2B done
#1 DONE 0.0s
ERROR: failed to solve: failed to read dockerfile: open Dockerfile-ARM64: no such file or directory
Error: Process completed with exit code 1. ``

But the path is absolute correct. Can anyone help with this issue?

@tonistiigi
Copy link
Member

--file flag is not an array and only takes one path. In your case that would mean that only Dockerfile-ARM64 is loaded. If you have platform-specific Dockerfiles you need to build them separately and can later merge them, for example with docker buildx imagetools create command.

Your error means though that the Dockerfile-ARM64 did not exist. I don't know why, but in your 2 examples you are using different context definition so there is no way both of your examples could work together.

@alanraju-aot
Copy link
Author

@tonistiigi I have not done the two above changes in a single CD action. Those are the two methods I have tried. Is their any way to build 2 Dockerfiles within a single context to build and push a Multi-arch image?

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

No branches or pull requests

2 participants