perf(docker): optimize build for 3-core system

- Set MIX_OS_DEPS_COMPILE_PARTITION_COUNT to 3 (match available cores)
- Enable Erlang JIT perf improvements
- Remove redundant hex/rebar installation calls (already done earlier)

This won't eliminate Docker compile time but should make better use of
the 3 available cores. Estimated savings: 1-2 minutes on build.
This commit is contained in:
Graham McIntire 2026-03-05 19:18:26 -06:00
parent f3758191fd
commit 8bad7c724e
No known key found for this signature in database

View file

@ -21,7 +21,10 @@ ARG BUILDER_IMAGE="docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION
ARG RUNNER_IMAGE="docker.io/debian:${DEBIAN_VERSION}"
FROM ${BUILDER_IMAGE} AS builder
ENV MIX_OS_DEPS_COMPILE_PARTITION_COUNT=6
ENV MIX_OS_DEPS_COMPILE_PARTITION_COUNT=3
# Enable parallel compilation with 3 cores
ENV ELIXIR_ERL_OPTIONS="+JPperf true"
ENV ERL_AFLAGS="-kernel shell_history enabled"
# Disable TTY for cross-architecture builds
ENV TERM=dumb
@ -46,8 +49,6 @@ COPY mix.exs mix.lock ./
COPY vendor vendor
RUN --mount=type=cache,target=/root/.hex \
--mount=type=cache,target=/root/.mix \
mix local.hex --force && \
mix local.rebar --force && \
mix deps.get --only $MIX_ENV
RUN mkdir config
@ -57,8 +58,6 @@ RUN mkdir config
COPY config/config.exs config/${MIX_ENV}.exs config/
RUN --mount=type=cache,target=/root/.hex \
--mount=type=cache,target=/root/.mix \
mix local.hex --force && \
mix local.rebar --force && \
mix deps.compile
RUN --mount=type=cache,target=/root/.mix \