This week’s big news in Google Cloud was the addition to Arm across a wide range of products, including GCE VMs, and GKE (both Standard and Autopilot). In an earlier post, I covered how to get an Arm-ready Autopilot cluster on day 1.
The recommended way to build images for Arm is with buildx. This is also how you can build multi-arch Docker images (ones that can run on both Arm and x86), which is a good idea to do for the time being due to the limited availability of Arm at launch.
But what if you’re using Google Cloud’s CI tool: Cloud Build?
While at the time of writing, the supplied docker builder image doesn’t offer Arm support, Cloud Build is able to run any containerized build step.. including the official docker container. Thus, we can run buildx inside Cloud Build by using the docker container:
steps: - name: 'docker' args: [ 'buildx', 'create', '--name', 'mybuilder', '--use' ] - name: 'docker' args: [ 'buildx', 'build', '--platform', 'linux/arm64,linux/amd64', '-t', 'us-central1-docker.pkg.dev/gke-autopilot-test/test/hello-ma:2', '--push', '.', ]
Once configured, submit the build like so, or setup a trigger.
gcloud builds submit --config cloudbuild.yaml .
For a full demo that you can try out yourself, here’s the code: https://github.com/WilliamDenniss/multi-arch-demo