Example repo for multi-arch Docker builds with Drone
Go to file
Ian Fijolek 978fb1991f
All checks were successful
continuous-integration/drone/push Build is passing
Merge branch 'test-branch'
2019-06-04 22:34:21 -07:00
.dockerignore Initial 2019-03-08 17:12:03 -08:00
.drone.yml Switch to more flexible ref matching 2019-06-04 22:20:52 -07:00
.gitignore Force build 2019-03-10 14:24:14 -07:00
Dockerfile Add some documentation 2019-06-04 17:28:26 -07:00
get_qemu.sh Debug working dir 2019-06-04 17:41:00 -07:00
Makefile Update example to show a more realistic implementation 2019-06-04 17:18:25 -07:00
manifest.tmpl Add a docker manifest 2019-03-10 15:35:08 -07:00
Readme.md Correct name of image tags 2019-06-04 22:33:07 -07:00

multiarch-pipeline-test

This is a test repo that serves as an example of publishing multi-arch Docker builds with Drone.

You can check the descriptions of each file below.

Builds from this pipeline are deployed to Docker Hub for validation as IamTheFij/multiarch-pipeline-test.

File descriptions

Makefile

This file is optional, but I like to use a Makefile to simplify iteration while on my local machine. There are comments inline, but the example is configured to set up a few simple targets for building and running images and containers for various target architechtures. It takes advantage of the depenency system in make to ensure the required qemu binaries are downloaded only one time to avoid uneeded http requests.

Dockerfile

This is the root of the "magic". This file includes inline documentation as well describing it's usage. Essentially, using a few buildargs, we can specify the base image and the qemu binary to include at build time.

Many library images now support multiple architechtures and do so by providing them under a different prefix repo.

However, some images use a tag suffix format. In fact, that will be the output of this pipeline. Something like user/image:linux-amd64 and user/image:linux-arm, etc. It's still possible to build based on those images. To do so, instead of a REPO arg, you can rename it to TAG_SUFFIX and update the FROM statement in the Dockerfile to something like FROM user/image:1.0.0-${TAG_SUFFIX}.

If you do rename the build arg, you must also rename the arg in the Makefile and .drone.yml.

.drone.yml

This is the build pipeline that Drone uses. Right now it's set up to run tests on all pushes and tags and then build and publish images on any tag or when a commit is pushed to master.

This is done by using distinct pipelines for each of these processes. First is the test pipeline, since we don't want to publish anything unless tests have passed.

After that, there are three distinct pipelines that can be run in parallel. One for each arch we would like to support. They are linux-amd64, linux-arm, and linux-arm64. These have two build steps. First to download the proper qemu binary, and second to build and push the image to Docker Hub. We take advantage of the autotagging feature of the Drone plugin to get convenient Docker image tags to match our git tags.

Once all three complete successfully, a final pipeline generates a Docker manifest and pushes it to Docker Hub. This allows Docker will map a client architechture to a particular Docker image. After this is pushed you should be able to docker run user/image on any of our supported architechtures and Docker will pull the correct image.