anuaralfetahe
Hi,
I’m trying to build a multi-platform Docker image based on elixir:1.17-otp-27. However, I’ve encountered an issue: the jason library fails to compile on arm64 because my host machine is running on amd64 architecture. I’ve also tried building the image on an arm64 machine, but then the build step for amd64 fails.
Does anyone have any suggestions on how to resolve this issue? I prefer not to create separate image tags, as the elixir:1.17-otp-27 base image already seems to supports both architectures.
Steps to reproduce:
- Create new project:
mix new myapp - Add
jasonas dependency in themix.exsfile:{:jason, "~> 1.4"} - Create Dockerfile with the following contents:
FROM elixir:1.17-otp-27
WORKDIR /app
COPY . .
RUN MIX_ENV=prod mix deps.get
RUN MIX_ENV=prod mix compile
RUN MIX_ENV=prod mix release
- Build the image:
docker buildx build --platform linux/amd64,linux/arm64 -t myapp_test .
This is the output:
=> ERROR [linux/arm64 5/6] RUN MIX_ENV=prod mix compile 21.1s
------
> [linux/arm64 5/6] RUN MIX_ENV=prod mix compile:
6.777 ==> jason
6.779 Compiling 10 files (.ex)
17.80 Compiling lib/encode.ex (it's taking more than 10s)
19.47 Compiling lib/decoder.ex (it's taking more than 10s)
20.03 Generated jason app
20.07 could not compile dependency :jason, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile jason --force", update it with "mix deps.update jason" or clean it with "mix deps.clean jason"
20.84 Segmentation fault (core dumped)
------
WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:9
--------------------
7 |
8 | RUN MIX_ENV=prod mix deps.get
9 | >>> RUN MIX_ENV=prod mix compile
10 | RUN MIX_ENV=prod mix release
--------------------
ERROR: failed to solve: process "/bin/sh -c MIX_ENV=prod mix compile" did not complete successfully: exit code: 139
Is there anything else I could do to build the same tag for both architectures? Thanks in advance ![]()
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 4 of 4 Posts
dimitarvp
A shot in the dark, maybe installing
build-essentialwith the distro’s package manager could help? Though I don’t thinkjasonhas any native dependencies…garazdawi
Is it specifically jason? Does it work for other libraries?
There have been issues in the past with qemu and the Erlang JIT, though they usually manifest earlier. Try setting
ERL_FLAGS="+JMsingle true"and see if that helps.anuaralfetahe
Actually
jasonlibrary had nothing to do with the problem. It was just the first library on my dependency list which failed with the error message.Adding
RUN ERL_FLAGS="+JMsingle true" MIX_ENV=prod mix compilefixed the issue for multi arch build, thank you!I’m wondering if this flag is only used during the compilation step it has no negative effect on the runtime?
garazdawi
It does not effect runtime if you only enable it during compilation. The flag disables some safeguards put in place that limits what an attacker can do if they find a vulnerability in the JIT.