Nov. 20, 2023
Building Docker images for multiple architectures

My little mdserver app has been a good way for me to start experimenting with the the devops side of things, especially building for Docker. Since I wanted to make the Docker image available for ARM Linux & x86 Linux I had a janky shell script that looked like this:
#!/bin/bash
# Extract the version number from package.json using jq
VERSION=$(jq -r .version package.json)
docker build --platform linux/amd64 -t iankulin/mdserver:$VERSION -t iankulin/mdserver:latest .
docker build --platform linux/arm64 -t iankulin/mdserver:arm64-$VERSION -t iankulin/mdserver:arm64-latest .
docker push iankulin/mdserver:arm64-$VERSION
docker push iankulin/mdserver:arm64-latest
docker push iankulin/mdserver:$VERSION
docker push iankulin/mdserver:latest
So I’d build two different versions, and use the tags to separate them. In the registry it’d look like this: