Docker Hub: support arm64 builds
Currently, Docker workflow supports building and pushing only amd64 images to Docker Hub, since compiling arm64 binaries with qemu/docker results in OOM, even on powerful machines with 32Gb RAM. Let's figure out the best way to support arm64.
Currently, proposed solutions:
- Integrate with CircleCI workflow
- Requires separate workflow, not compatible with GitHub actions.
- Requires 3 CI jobs: two for creating
amd64andarm64respectfully and one for combining this images into manifest. Source: Multi-Arch Build With Docker Buildx and CircleCi - Simplex Chat need to apply for free tier plan for Open Source projects.
- Selfhost Github runner on
aarch64hardware.- Need to figure out where to host
armserver. - Set up Github runner (pretty straightforward).
- Adjust
docker-image.yml
- Need to figure out where to host
Just to add to this: CircleCI has native ARM support, which is why it's expected to work.
If the self-hosted GitHub Actions runner solution is chosen, you still need three CI jobs, just like with CircleCI, because the arm64 build needs to run on the self-hosted runner while the others run on the GitHub-hosted runners.
you still need three CI jobs ... because the arm64 build needs to run on the self-hosted runner while the others run on the GitHub-hosted runners
So we can not specify something like...
jobs:
build-and-push:
name: Build and push Docker image
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- application: smp-server
dockerfile: build.Dockerfile
- os: [ubuntu-latest, self-hosted]
...
…to build all the images to one manifest on separate runners automagically?
Actually yes, you could do something like that. Then you would only need two jobs, one with a matrix to build the images, and one for making the manifest. You could also use some Bash magic to get the architecture for the image tags, like so:
...
jobs:
build-and-push-images:
name: Build and push Docker image
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, self-hosted]
include:
- application: smp-server
dockerfile: build.Dockerfile
runs-on: ${{ matrix.os }}
steps:
...
- name: Get machine architecture for image tags
id: arch
run: |
if [ "$(uname -m)" = "x86_64" ]; then
echo "tag=amd64" >> "$GITHUB_OUTPUT"
elif [ "$(uname -m)" = "aarch64" ]; then
echo "tag=arm64" >> "$GITHUB_OUTPUT"
fi
- name: Extract metadata for Docker image
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.application }}
flavor: |
latest=auto
suffix=-${{ steps.arch.output.tag }},onlatest=true
tags: |
type=semver,pattern=v{{version}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
...
create-and-push-manifest:
name: Create and push Docker manifest
needs: build-and-push-images
...
Hi, did you guys figure out how to build the server without OOM killing everything? I've tried building docker image on my machine with 16G RAM (8GB zram) and it killed all of my desktop processes.
You could potentially ask for sponsorship for aarch64 VM's from https://osuosl.org/services/aarch64/
The good news is that arm runners are coming to Github. The bad news is that it will be available as private beta from January 2024 so probably another half a year or more from then to general availability.
There's M1 runner available from today. I'm not sure how to integrate it fully to current workflow but if someone has an idea we could test and finally upload arm64 to DockerHub.
@epoberezkin could you try? It looks like they added it today https://github.blog/changelog/2024-06-24-github-actions-ubuntu-24-04-image-now-available-for-arm64-runners/
in the meantime, is there a way to setup our docker-compose files to build it ourselves?
in the meantime, is there a way to setup our docker-compose files to build it ourselves?
I've built it many times in the past. If you have arm64 device then simply build it like described here https://github.com/simplex-chat/simplexmq?tab=readme-ov-file#using-docker-1. As for the compose you can just paste the docker run into some LLM and it will output the compose easily. I know because I've tried that on Perplexity.
https://github.blog/changelog/2024-09-03-github-actions-arm64-linux-and-windows-runners-are-now-generally-available/ It's generally available but only on Team and Enterprise plans :(