mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-03-21 21:41:48 +00:00
49 lines
1.4 KiB
Docker
49 lines
1.4 KiB
Docker
ARG ALPINE_VERSION=3.18.4
|
|
ARG OTP_VERSION=26.1.1
|
|
ARG ELIXIR_VERSION=1.15.6
|
|
ARG BUILDER_IMAGE="firezone/elixir:${ELIXIR_VERSION}-otp-${OTP_VERSION}"
|
|
ARG RUNNER_IMAGE="alpine:${ALPINE_VERSION}"
|
|
|
|
FROM ${BUILDER_IMAGE} as compiler
|
|
# prepare build dir
|
|
WORKDIR /app
|
|
# install mix dependencies
|
|
COPY mix.exs mix.lock ./
|
|
COPY apps/domain/mix.exs ./apps/domain/mix.exs
|
|
COPY apps/web/mix.exs ./apps/web/mix.exs
|
|
COPY apps/api/mix.exs ./apps/api/mix.exs
|
|
COPY config config
|
|
ARG MIX_ENV="prod"
|
|
RUN mix deps.get --only ${MIX_ENV}
|
|
RUN mix deps.compile --skip-umbrella-children
|
|
COPY priv priv
|
|
COPY apps apps
|
|
# Install pipeline and compile assets for Web app
|
|
RUN cd apps/web \
|
|
&& mix assets.setup \
|
|
&& mix assets.deploy
|
|
# Compile the release
|
|
RUN mix compile
|
|
|
|
FROM ${BUILDER_IMAGE} as builder
|
|
WORKDIR /app
|
|
COPY --from=compiler /app /app
|
|
COPY rel rel
|
|
ARG APPLICATION_NAME
|
|
ARG MIX_ENV="prod"
|
|
RUN mix release ${APPLICATION_NAME}
|
|
|
|
# start a new build stage so that the final image will only contain
|
|
# the compiled release and other runtime necessities
|
|
FROM ${RUNNER_IMAGE} AS runtime
|
|
WORKDIR /app
|
|
RUN apk add -u --no-cache libstdc++ ncurses-libs openssl curl
|
|
ARG APPLICATION_NAME
|
|
ENV APPLICATION_NAME=$APPLICATION_NAME
|
|
# Only copy the final release from the build stage
|
|
ARG MIX_ENV="prod"
|
|
COPY --from=builder /app/_build/${MIX_ENV}/rel/${APPLICATION_NAME} ./
|
|
# Change user to "default" to limit runtime privileges
|
|
# USER default
|
|
CMD bin/server
|