processone / ejabberd

Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
https://www.process-one.net/en/ejabberd/
Other
6.06k stars 1.51k forks source link

Building the container crashes with QEMU + arm64 + Erlang/OTP 25 #3983

Closed badlop closed 1 year ago

badlop commented 1 year ago

Since ejabberd 17.03, a container image is published in Docker Hub for amd64 architecture.

Since ejabberd 22.05, there is an alternative container image available in GitHub Container Registry. It includes variants for amd64... and arm64 thanks to QEMU. It is built directly from the source code using this Dockerfile. In fact, the image is built automatically for every ejabberd release and every commit using this GitHub Workflow, which uses QEMU to allow building for the arm64 architecture.

Unfortunately, using QEMU + arm64 + Erlang/OTP 25 crashes with segmentation fault. For example, when building the ejabberd container for arm64 using Alpine 3.17, which includes Erlang 25, the action crashes:

#18 [linux/arm64 build  3/10] RUN mix local.hex --force     && mix local.rebar --force
#18 1.302 Segmentation fault (core dumped)
#18 ERROR: process "/bin/sh -c mix local.hex --force     && mix local.rebar --force" did not complete successfully: exit code: 139

The issue is tracked in QEMU's bug tracker: Erlang/OTP 25 JIT on AArch64 fails in user mode emulation

An obvious workaround would be to keep using Alpine 3.16, which includes the safe Erlang/OTP 24 for building those container images, to be able to use QEMU to build the arm64 architecture. This is acceptable now, and upgrade can be delayed hoping that a definitive solution is found in QEMU or Erlang...

But Sando38 has prepared an alternative way to build the container in Github Actions: using the binary installers. In that case, there would be multiple stages in .github/container/Dockerfile, and the METHOD argument would control whether: