Files
wanderer/Dockerfile
T
Dmitry Popov 4136aaad76 Initial commit
2024-09-18 01:55:30 +04:00

57 lines
1.2 KiB
Docker

ARG BUILDER_IMAGE="wandererltd/build-base:latest"
ARG RUNNER_IMAGE="wandererltd/runner-base:latest"
FROM ${BUILDER_IMAGE} as builder
# prepare build dir
WORKDIR /app
# set build ENV
ENV MIX_ENV="prod"
# install mix dependencies
COPY mix.exs mix.lock ./
RUN rm -Rf _build deps && mix deps.get --only $MIX_ENV
RUN mkdir config
# copy compile-time config files before we compile dependencies
# to ensure any relevant config change will trigger the dependencies
# to be re-compiled.
COPY config/config.exs config/${MIX_ENV}.exs config/
COPY priv priv
COPY lib lib
COPY assets assets
RUN mix compile
RUN mix assets.deploy
# Changes to config/runtime.exs don't require recompiling the code
COPY config/runtime.exs config/
COPY rel rel
RUN mix release
# start a new build stage so that the final image will only contain
# the compiled release and other runtime necessities
FROM ${RUNNER_IMAGE}
WORKDIR "/app"
COPY --chmod=755 ./rel/docker-entrypoint.sh /app/entrypoint.sh
RUN chown nobody /app
# set runner ENV
ENV MIX_ENV="prod"
# Only copy the final release from the build stage
COPY --from=builder --chown=nobody:root /app/_build/${MIX_ENV}/rel/wanderer_app ./
USER nobody
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["run"]