DEV Community

Josh Kasuboski
Josh Kasuboski

Posted on • Originally published at joshkasuboski.com on

Building Multiarch Images

I wanted to use fathom on my Raspberry Pi k3s cluster, but they didn't publish a compatible ARM image. Not to be deterred I forked the repo and built my own.

How does one build for multiple architectures easily

Docker has a tool called buildx. It acts as a frontend to buildkit and allows building images for multiple platforms at once.

I followed this guide to create a GitHub Actions workflow to build it.

GitHub Actions it up

You can skip ahead and look at my final workflow here.

There was already a buildx action. The workflow ends up seemingly simple.

  • Checkout the repo
  • Set up buildx
  • Login to DockerHub
  • Build for linux/amd64,linux/arm/v7,linux/arm64

That last part includes the platforms I would care about (for now). amd64 is for your run of the mill computer, arm/v7 being what is on my Pi thanks to 32-bit Raspbian, and arm64 being a potential if I switch the OS on my Pi.

I did have to make a change to the repo other than just adding the workflow. The build step had the GOARCH variable set to amd64. This caused the build to always output an amd64 binary, unsurprisingly. I realized this after two 16 minute builds…

The workflow works well, but every run so far was between 14mins and 30mins… not exactly fast.

Moving Forward

There have been a number of images that aren't multi-arch that I want to run. I may look into forking and building those, but it would be nice to have a simpler solution with me not managing it.

I could contribute to multi-arch-images instead. They seem to be doing something similar but just copying the Dockerfiles needed.

Top comments (0)