factoriotools / factorio-docker

Factorio headless server in a Docker container
https://hub.docker.com/r/factoriotools/factorio/
MIT License
888 stars 218 forks source link

add support for ARM #485

Closed mcrossen closed 4 months ago

mcrossen commented 4 months ago

In my quest to run factorio headless server on raspberrry pi I came across 'box64'. What's nice about box64 is it doesn't require emulating an entire ARM host, so it should be more performant than my other attempts.

PREREQUISITES

In order for this to work, we need a different docker base image. PR#469 already fixes this. I see the PR is approved, but not merged. I copied the changes from that PR into my first commit, so the changed files of this PR will look a lot cleaner once that PR is merged.

CHANGES

I divided the changes into two commits: dockerfile changes, and build automation changes.

Changes to the dockerfile allow the image to be built on arm64 hosts. Go ahead and try it on your raspberry pi! Inside the dockerfile, it checks if the host is ARM64. If it is, then it installs box64.

Changes to the build automation allow github actions to build and release both the x86 version and the arm64 version in parallel. This requires using docker buildx. It also requires qemu to emulate an arm64 host while building. Don't worry, builds on your local machine shouldn't require these additional dependencies unless you pass --multiarch into the build script. When users pull the docker container after this is published, it should automatically pull the right version based on their host architecture - no changes to the documentation required.

TESTING

To test, I built and ran this on my raspberry pi. Then I connected to the factorio server from a different computer. I walked around a bit on the new map and then signed out.

I also tested the github actions workflow by pushing a temporary change that allowed a manual trigger. I used this trigger to build the docker images.

mcrossen commented 4 months ago

Thanks for merging. Looks like it's working because I'm starting to see the arm version show up in docker hub. It has to rebuild every version in arm so it might take a while to complete

If any user mentions issues with the arm builds, please tag me so I can look into it. You could also remind them that arm builds are experimental

Fank commented 4 months ago

I see thanks. And i will ping you when i notice any arm issues, thanks for the support.