fix: set EXLA make_args via config.exs instead of mix run -e
Some checks failed
Build base image / Build and push base image (push) Successful in 21s
Build and Push / Build CI test image (push) Successful in 2m27s
Build and Push / Build and Push Docker Image (push) Failing after 15m44s

mix run -e starts the full OTP application which requires hackney for
Swoosh. Instead, put config :exla, :make_args, [-j1] in the temp
config.exs — EXLA reads it at compile time via Application.get_env.
This commit is contained in:
Graham McIntire 2026-08-05 13:34:07 -05:00
parent 07dbcbc428
commit a0aa6f0986

View file

@ -31,16 +31,16 @@ WORKDIR /tmp/exla_warm
COPY mix.exs mix.lock /tmp/exla_warm/
COPY vendor /tmp/exla_warm/vendor
# Minimal config — nx needs :default_backend to exist.
# Set :exla make_args to -j1 so C++ compiles serially (the default
# nproc-2 can cause parallel OOM kills on CI runners).
RUN mkdir -p /tmp/exla_warm/config && \
printf 'import Config\nconfig :nx, :default_backend, EXLA.Backend\n' > /tmp/exla_warm/config/config.exs
printf 'import Config\nconfig :nx, :default_backend, EXLA.Backend\nconfig :exla, :make_args, ["-j1"]\n' > /tmp/exla_warm/config/config.exs
# Compile all deps. EXLA's Makefile defaults to -O3 which OOM-kills g++
# on low-memory CI runners. Patch it to -O0 before compilation.
# Also override make_args to -j1 (EXLA defaults to nproc-2 parallel jobs)
# since elixir_make's sanitized env blocks MAKEFLAGS/DEBUG from reaching make.
RUN mix deps.get && \
sed -i 's/-O3/-O0/g' deps/exla/Makefile && \
mix run -e 'Application.put_env(:exla, :make_args, ["-j1"])' && \
mix deps.compile
# Save the full build cache (libexla.so + .o files + xla_extension lib)