# Auto-generated by GitBlixt for Elixir/Phoenix apps ARG ELIXIR_VERSION=1.19.5 ARG OTP_VERSION=28.4.1 ARG DEBIAN_VERSION=trixie-20260316-slim ARG BUILDER_IMAGE="docker.io/hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}" ARG RUNNER_IMAGE="docker.io/debian:trixie-slim" # --- deps --- FROM ${BUILDER_IMAGE} AS deps RUN apt-get update \ && apt-get install -y --no-install-recommends build-essential git ca-certificates curl \ && curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \ && apt-get install -y --no-install-recommends nodejs \ && rm -rf /var/lib/apt/lists/* WORKDIR /app RUN mix local.hex --force && mix local.rebar --force ENV MIX_ENV="prod" COPY mix.exs mix.lock ./ RUN mix deps.get --only $MIX_ENV RUN mkdir config COPY config/config.exs config/${MIX_ENV}.exs config/ RUN mix deps.compile # --- builder --- FROM deps AS builder ENV MIX_ENV="prod" COPY priv priv COPY lib lib RUN mix compile COPY assets assets RUN if [ -f assets/package.json ]; then npm install --prefix assets --production; fi RUN mix assets.deploy 2>/dev/null || true COPY config/runtime.exs config/ RUN mix release --overwrite # --- runner --- FROM ${RUNNER_IMAGE} AS final RUN apt-get update \ && apt-get install -y --no-install-recommends \ libstdc++6 openssl libncurses6 locales ca-certificates curl \ && locale-gen en_US.UTF-8 \ && rm -rf /var/lib/apt/lists/* \ && sed -i 's/^tty:x:5:/tty:x:5:nobody/' /etc/group ENV LANG=en_US.UTF-8 ENV LANGUAGE=en_US:en ENV LC_ALL=en_US.UTF-8 ENV MIX_ENV="prod" ENV PHX_SERVER=true ENV PORT=4000 WORKDIR /app RUN chown nobody /app COPY --from=builder --chown=nobody:root /app/_build/prod/rel/ /tmp/rel/ RUN cp -r /tmp/rel/*/* ./ && rm -rf /tmp/rel USER nobody EXPOSE ${PORT} CMD sh -c "if [ -f /app/bin/server ]; then exec /app/bin/server; else exec /app/bin/$(ls /app/bin/ | grep -v '.bat' | head -1) start; fi"