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

feat: docker multi arch images #13

Merged
merged 2 commits into from
Jul 12, 2023
Merged

Conversation

cheyer
Copy link
Collaborator

@cheyer cheyer commented Jun 28, 2023

This closes #12.

We need to build our docker images for multiple architectures (amd64 and arm64) since we need to be able to develop on MacBooks based on Apple silicon (M1 etc.).

This PR uses docker buildx to simply build multi arch images. The docker buildx build also includes pushing the images to the registry (with --push), so we can get rid of the separate docker push commands.
In order to use docker buildx we need to setup it using the setup-buildx-action action.

The github action mentioned in the docker guide is deprecated. However it mentions the correct docker gh actions that we can use:

      # https://github.com/docker/setup-qemu-action
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      # https://github.com/docker/setup-buildx-action
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1

How to test (locally)

I tested the docker buildx command locally on MacBook Pro with M2 chip creating a test image for the data graph repository:

docker buildx build . -t ghcr.io/dot-base/data-graph:2023-06-28-test --push --platform linux/amd64,linux/arm64

Running the command above for the 1st time will result in an error, since we are missing the correct driver:

[+] Building 0.0s (0/0)
error: multiple platforms feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")

Therfore, we need to create a docker driver first:

docker buildx create --use

If we run the buildx command again, it will work successfully.

docker buildx build . -t ghcr.io/dot-base/data-graph:2023-06-28-test --push --platform linux/amd64,linux/arm64

It successfully creates an image for both architectures. See registry

image

Reference

cheyer added 2 commits June 28, 2023 15:46
Following the docker guide on buildling images for multiple architectures,
we need to setup buildx first. The blog article mentions a custom github action
that is no longer maintaned. However, it references official docker github
actions that are we can use to setup buildx.

References
- Docker guide: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/
- GH Action Custom Setup Buildx: https://github.com/crazy-max/ghaction-docker-buildx
- GH Action Qemu: https://github.com/docker/setup-qemu-action
- GH Action Buildx: https://github.com/docker/setup-buildx-action
@cheyer cheyer self-assigned this Jul 10, 2023
@cheyer cheyer added the Status: Review Needed Please review the corresponding code. label Jul 10, 2023
Copy link
Contributor

@Zbozi Zbozi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing the commands locally with the medical-dashboard resulted in three images:

See: https://github.com/dot-base/medical-dashboard/pkgs/container/medical-dashboard/108518743?tag=test-review

The command i used was:

  • docker buildx build . -t ghcr.io/dot-base/medical-dashboard:test-review --push --platform linux/amd64,linux/arm64 --build-arg FONTAWESOME_NPM_AUTH_TOKEN=xxxx

@cheyer
Copy link
Collaborator Author

cheyer commented Jul 12, 2023

Testing the commands locally with the medical-dashboard resulted in three images:

See: https://github.com/dot-base/medical-dashboard/pkgs/container/medical-dashboard/108518743?tag=test-review

The command i used was:

  • docker buildx build . -t ghcr.io/dot-base/medical-dashboard:test-review --push --platform linux/amd64,linux/arm64 --build-arg FONTAWESOME_NPM_AUTH_TOKEN=xxxx

I could reproduce this, now that I have the latest version of Docker and docker buildx.
This is related to Provenance attestations which are now automatically created with newer versions of docker. Provenance attestations include facts about the build process. This is getting important, as people parallelise building multiarch images on different machines, so build times are faster (we do not do this).
How this information is stored, causes the Github Registry to show more architectures, so it seems to be a bug on Github's side.

I think we have 2 alternatives:

  • do nothing, as Github will fix this eventually and the information should be displayed correctly
  • call docker buildx build with --provenance=false to not generate this information (data graph image build with this command)

What do you think? @Zbozi

Related Issues:

@cheyer
Copy link
Collaborator Author

cheyer commented Jul 12, 2023

We decided to not change it for now, as Github should fix it eventually.

@cheyer cheyer merged commit ddfcaa8 into master Jul 12, 2023
@cheyer cheyer removed the request for review from andreakreichgauer July 13, 2023 07:58
@Zbozi Zbozi removed the Status: Review Needed Please review the corresponding code. label Jul 18, 2023
@velramiir velramiir deleted the feat/docker-multi-arch-images branch February 15, 2024 15:14
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

Successfully merging this pull request may close these issues.

Build docker multi arch images (ARM support)
2 participants