tmjoen

tmjoen

Building Elixir/Erlang linux/amd64 application image on Apple Silicon

I have a multi stage docker file and building the node assets works fine with both --platform linux/arm64 and linux/amd64. I can make the elixir/erlang image work with --platform linux/arm64, but when I try linux/amd64 qemu blows up:

FROM --platform=linux/amd64 hexpm/elixir:1.12.3-erlang-24.1.5-ubuntu-focal-20210325 AS deps

ARG MIX_ENV=prod
ARG HEX_MIRROR_URL=https://repo.hex.pm

RUN /usr/local/bin/mix local.hex --force && \
    /usr/local/bin/mix local.rebar --force

RUN apt-get -qq update && apt-get install -y \
    git \
    unzip \
    build-essential \
    wget \
    sudo

WORKDIR /opt/app

COPY config/ ./config
COPY mix.exs mix.lock /opt/app/

RUN mix deps.get --only $MIX_ENV

Results in

#12 [2/6] RUN /usr/local/bin/mix local.hex --force &&     /usr/local/bin/mix local.rebar --force
#12 sha256:690d11d4149aae5005ba9d4f6d1bfcb55259a6efa519068eac1913c8c5c6a1a1
#12 1.540 qemu: uncaught target signal 11 (Segmentation fault) - core dumped
#12 1.546 Segmentation fault
#12 ERROR: executor failed running [/bin/sh -c /usr/local/bin/mix local.hex --force &&     /usr/local/bin/mix local.rebar --force]: exit code: 139

Anyone else getting this problem? Or found a way around it?

Thanks for reading!

Marked As Solved

dom

dom

The crash happens when JIT is enabled. Disabling the JIT, using pre-JIT Erlang (23.x or older), or using an old OS that doesn’t have a version of gcc recent enough to support C++17 (required to compile the JIT) will work around it.

Also Liked

tmjoen

tmjoen

Some more digging here. It’s not OTP24 that fails, it is OTP24 on some distros:

OTP24 on Ubuntu Focal FAILS (hexpm/elixir:1.13.0-rc.1-erlang-24.1.5-ubuntu-focal-20210325)
OTP24 on Ubuntu Bionic FAILS (hexpm/elixir:1.13.0-rc.1-erlang-24.1.5-ubuntu-bionic-20210325)
OTP24 on Ubuntu Xenial WORKS (hexpm/elixir:1.13.0-rc.1-erlang-24.1.5-ubuntu-xenial-20210114)
OTP24 on Debian Stretch WORKS (hexpm/elixir:1.13.0-rc.1-erlang-24.1.5-debian-stretch-20210902)
OTP24 on Debian Bullseye FAILS (hexpm/elixir:1.13.0-rc.1-erlang-24.1.5-debian-bullseye-20210902)
OTP24 on Alpine 3.14.2 FAILS (hexpm/elixir:1.13.0-rc.1-erlang-24.1.5-alpine-3.14.2)

tmjoen

tmjoen

Not really.

I raised an issue on the docker for mac github, but it was closed and deferred to qemu.

There is a new qemu version out, but it hasn’t been picked up by docker yet (afaict)

jhogberg

jhogberg

Erlang Core Team

This is due to a bug in qemu, see Erlang/OTP 25 JIT on AArch64 fails in user mode emulation (#1034) · Issues · QEMU / QEMU · GitLab.

Older images most likely work because they don’t provide a C++ compiler capable of compiling the JIT, making it fall back to the interpreter.

Last Post!

user20251023

user20251023

Add ENV ERL_FLAGS="+JPperf true" worked for me.

Where Next?

Popular in Questions Top

Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement