InstaFix
                                
                                 InstaFix copied to clipboard
                                
                                    InstaFix copied to clipboard
                            
                            
                            
                        [devops] Cross-compile to, and add aarch64 support in Docker images
In order to run the application in ARM 64-bit hardware, such as Raspberry Pi's or Mac M-series processors, it needs to be cross-compiled using GOARCH=arm64.
To do this, a go build needs to be ran for both x86_64 (default/current arch) and arm64.
Both binaries need to be kept with separate names, thus the x86_64 can remain as /app/instafix, and the arm binary as /app/instafix-arm.
Then, instead of running the application directly as an entrypoint, it will need to be ran from an entrypoint script that chooses between both available binaries depending on the running device's architecture.
Bonus points if the entrypoint shell script also includes a health check reporting back to the Docker engine.
I will be submitting a PR for this later on, as so far I have kept a separate fork that allows me to run ARM-only Docker images of instafix, and I would like to get rid of that since it's troublesome to keep up to date with (your) upstream.
Partly solved by @AstralJaeger in #112/#111. The only thing that's missing is building (at GitHub CI's build-time) all supported variants, save them into separate files, then adding an init script that gets called by the Dockerfile's entrypoint and checks the architecture and runs the corresponding binary. What do you think, @AstralJaeger, would that still work for your purpose?
Edit: I have some spare time this week so I can submit the PR for this soon :)
Sorry, I was on vacation for the week, I think it should already be done, no runtime check needed, that will be performed by the container runtime since the product of the build is a multi-architecture container which contains the variants for amd64 and arm64 (whoever decided to name 2 fundamentally different architectures this similarly deserves slow internet).
I just pulled the latest container and tried to run it on my M1 Mac and it worked out of the box. I encourage you to play around with it, as meantioned in #111 you can try it out on the Oracle Cloud Infrastructure Free Tier, they provide a 4 Core 24Gb ARM VPS (credit card required, I don't get sponsored or use OCI professionally either).
Any changes that still allow the image to run on ARM are fine by me and will still work for my purpose, worst case I'll rely on the current master sha. :D
Ahh, I see now. I missed reading the line with: platforms: linux/amd64, linux/arm64... in the push to the container registry step. Quite a nice setup! And indeed, with this one there should be no manual work needed at the runtime, should all be handled by the dockerd/containerd engine when they pull the correct arch's image. Will close this issue now, thanks!
I'm glad you liked the setup, the initial version I cooked up a year ago took me a while to figure out.