DevSecOps and Automation on Power

 View Only

Building multi-arch container images with CircleCI

By Mayur Waghmode posted Thu September 29, 2022 10:00 AM

  
IMPORTANT: to create multi-arch image, you must ensure that the base image you are using is available for your target architectures. In this example, we are building a multi-arch image to run on x86_64 ppc64le, s390x and arm64 and the base image we are using (Ubuntu), is available for each architecture.
  1. In your GitHub project create a .circleci directory.
  2. In the newly created .circleci directory, create a config.yml and add this code to it.
  3. Commit and push the changes.
  • Runs a multiarch/qemu-user-static docker image to enable the execution of different multi-architecture containers by QEMU and binfmt_misc
  • Creates a docker context ( docker context create ) and then use it ( docker buildx create --use )
  • Sets DOCKER_EXPERIMENTAL=enabled when using docker buildx
  • Creates the container images and manifest using docker buildx  for all the architectures specified in the --platform argument and pushes the newly created image to a remote registry.
  1. For this step, you will need a CircleCI account. Visit the CircleCI signup page and click “Sign Up with GitHub”. You will need to give CircleCI access to your GitHub account to run your builds. If you already have a CircleCI account then you can navigate to your dashboard.
  2. Next, you need to add your repo as a new project on CircleCI. To add your new repo, ensure that your GitHub account is selected in the dropdown in the upper-left, find the repository you just created below, and click the Setup project button next to it.
  1. On the CircleCI web app, click the Project Settings button on the project’s individual Pipelines page.
  2. Click on Environment Variables in the side navigation.
  3. Click the Add Variable button to enter the name and value of the new environment variable.

Step 7: Re-trigger the CircleCI build

Step 8: Test your multi-arch image

docker manifest inspect --verbose quay.io/mayurwaghmode111/circleci-multi-arch#The output should have json like:
....
# "platform": {
# "architecture": "ppc64le",
# "os": "linux",
# }
# ...
# "platform": {
# "architecture": "s390x",
# "os": "linux"
# }
# ....
# "platform": {
# "architecture": "arm64",
# "os": "linux",
# }
# ...
# "platform": {
# "architecture": "amd64",
# "os": "linux",
# }
# ...

Permalink