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 aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
I’d like to create a file with 600 permissions (rw-------), but there’s a race condition if I create it and then change the permissions. ...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
When I use Mix.install with a git dependency, using git@github.com:... how do I change the SSH identity used?
I’ve got two Github accoun...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #security
- #elixirconf-eu
- #api
- #forms
- #performance










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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.