Docker image for arm64
thomas-zahner opened this issue · comments
Currently there seems to be only a Docker image available for the amd64 platform. I would have liked to run the Docker image on my server with arm64 architecture.
Expected behaviour
Expected the following to work:
$ docker run --platform linux/arm64 -u "$(id -u):$(id -g)" -v $PWD:/app --workdir /app ghcr.io/getzola/zola:v0.19.1 build
Actual behaviour
The above command fails with:
Unable to find image 'ghcr.io/getzola/zola:v0.19.1' locally
v0.19.1: Pulling from getzola/zola
Digest: sha256:6e4f78e3f1338b2f117e4a88106ddf01bc2727bf7dcd06a97a8ea36e0fe14edd
Status: Image is up to date for ghcr.io/getzola/zola:v0.19.1
docker: image with reference ghcr.io/getzola/zola:v0.19.1 was found but does not match the specified platform: wanted linux/arm64, actual: linux/amd64.
Fix
As a workaround I manually compiled zola on the server and it worked like a charm. But adding arm64 releases to the Docker Hub would benefit other users as well. Could we do that?
I think adding something like platforms: linux/amd64,linux/arm64/v8
to cd-workflow.yml might be enough already.
I would take a PR for it
So I've managed to build for arm64 in my fork. But building it with GitHub runners in Docker (Docker in Docker) is very slow, I think mainly because of QEMU emulation. The build time was ~100 minutes where without the ARM build it takes ~6 minutes
As this is probably not viable we should instead simply copy the previously built and released binaries into the Docker images. This is also what the lychee project does.
I notice that you build your binaries not on GitHub but on Azure. What's the reason for that? I have no experience with Azure and I'm not sure if I could test this in my fork.
But building it with GitHub runners in Docker (Docker in Docker) is very slow, I think mainly because of QEMU emulation. The build time was ~100 minutes where without the ARM build it takes ~6 minutes
Damn that's way too slow :/
I notice that you build your binaries not on GitHub but on Azure. What's the reason for that?
GH actions didn't exist back then and it's working well so no reasons to change
I agree, that's way too slow..
So a solution would be to not build zola inside of Docker at all. As we build the release binaries already, we can just reuse them in Docker. This would even make the x86 build much quicker.
The problem with this however is that the build on Azure need to be awaited before building the Docker images and I'm not sure if that is possible.
I'm also interested in native Linux arm binaries and docker images. Would make my workflow much easier to just assume there is the right docker image for my arch.
I also made the experience that compiling rust in docker QEMU emulated is slow as heck. So I would be +1 to reuse binaries if they are already present. I compiled zola in Docker on a native ARM64 VM (4 Cores, 8GB RAM) and it took 11min. GitHub has hosted ARM runners, unfortunately only for Teams/Enterprise.
Notifying GitHub Actions via azure is possible via a webhook trigger - you just need a token which I'm sure you already have on azure to upload artifacts to GitHub.
Another alternative would be to port everything to GH Actions to just set job order and don't need any long lived tokens to create releases.
Let us know what you think will be best and I will be happy if I can support on any of this
If we can reproduce the exact same setup (including filenames of the archives for the releases), I'm happy to move to GH actions.
I created a PR in #2629
Still need to cross compile linux arm - but it is quite fast 6m46s.
When reusing binaries the docker build would just to download the release binaries and upload. Should not take longer then 1min.
@hegerdes Thanks for the PR 👍