phoenixframework / phoenix

Peace of mind from prototype to production
https://www.phoenixframework.org
MIT License
21.45k stars 2.88k forks source link

Generated Dockerfile fails to compile on arm64 #5932

Closed SuddenGunter closed 2 months ago

SuddenGunter commented 2 months ago

Environment

Actual behavior

Arm builds inside docker fail with

8.349 Error while loading project :mime at /app/deps/mime
8.981 Segmentation fault (core dumped)
------
Dockerfile:46
--------------------
  44 |     # to be re-compiled.
  45 |     COPY config/config.exs config/${MIX_ENV}.exs config/
  46 | >>> RUN mix deps.compile
  47 |     
  48 |     COPY priv priv
--------------------
ERROR: failed to solve: process "/bin/sh -c mix deps.compile" did not complete successfully: exit code: 139

Steps to reproduce:

  1. Create new Phoenix app mix phx.new multiplatform
  2. Create docker release in that app mix phx.gen.release --docker
  3. Try to build that Dockerfile targeting arm64

I've a sample repo that implements all 3 steps:

linux/amd64 image is being build fine, issue only affects arm64

Expected behavior

both amd64 and arm64 images are built correctly

SuddenGunter commented 2 months ago

UPD: It turns out to be an old known issue when running Erlang VM under QEMU.

fixed using ENV ERL_FLAGS="+JMsingle true" in my dokerfile after FROM ${BUILDER_IMAGE} as builder line