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.

dom

dom

I wish I knew! I also have that problem and I don’t know how to debug it :sweat_smile:

Klohto

Klohto

It’s been handled poorly. Hopefully this time the issue might stay open so at least we learn where the culprit is or how to work around it Yet Another QEMU Segmentation Fault Issue · Issue #6261 · docker/for-mac · GitHub

Where Next?

Popular in Questions Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
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
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
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement