Golang arm64 docker image with CircleCI arm machine

NamiOps
2 min readApr 17, 2021

--

Photo by Chaitanya Tvs on Unsplash

Hi, several weeks ago I wrote about “Build multi-arch docker image with CircleCi” and “Build golang multi-arch docker image with Github Action”. Today, I want to introduce you a simple way how to build golang arm docker image with CircleCI.

This method will help you stay away from using QEMU to build arm image. (Because QEMU is quite slow)

How simple an arm64 docker image be built

Basically, if you don’t select the image platform in the Dockerfile, docker will automatically try pull the image which have same CPU architecture of the machine docker running for the build.

So, just please make sure your project having:

  • Your Dockerfile just extend from an official image such as: scratch, golang or arm only image like arm64v8/debian.
  • Run “docker build” from inside an Arm Machine such as: Raspberry Pi, Aws Gravition Ec2 instance, or CircleCi Arm Machine (our case in this article)

In this article, we use CircleCi arm machine

CircleCI have publiced arm.machine recently, so you will just update your project’s CircleCI config.yaml to use that resource (arm.medium or arm.large):

Before, you will have to send a request to access CircleCI Arm Machine via this arm form.

version: 2.1
commands:
setup:
steps:
- checkout
- run:
name: Update arm machine
command: |
sudo apt-get update
jobs:
build-medium:
machine:
image: 'ubuntu-2004:202101-01'
resource_class: arm.medium
steps:
- setup
- run:
name: Login to Docker Hub
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
- run:
name: Build multiarch docker image and push
command: |
docker build -t namiops/golang-arm64 .
docker push namiops/golang-arm64
workflows:
version: 2
build-and-deploy:
jobs:
- build-medium:
context:
- DOCKER_HUB

(Document about the resource_class above https://circleci.com/docs/2.0/arm-resources/)

Finally, just submit the update, CircleCI will execute the build with “Arm Linux Medium”

Github repository

Please feel free to checkout our github repository to figure out how circleci config.

Thanks

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

NamiOps
NamiOps

Written by NamiOps

A programmer, system architect and devops engineer

Responses (1)

Write a response