mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
~~This is an attempt to fix the CI bug
[here](https://github.com/firezone/firezone/actions/runs/5491388141/jobs/10007864417#step:4:1638)
possibly introduced in
[d9eb2d18](https://github.com/firezone/firezone/commit/d9eb2d18#diff-88bd94db0d5cfd5f0617b7c4ed48c0212597378ed7e28714c5d86c95999b4c7dR29)
and uncovered / exacerbated in Elixir 1.15~~
Edit: looks like this ended up being a couple cache issues with GitHub
actions:
1. The `elixir_api-container-build` cache would always overwrite the
`elixir_web-container-build` on subsequent builds of the same
`github.ref_name` (cache is scoped to branch name by default), leading
to the consistent error `Elixir.Web.Mailer.NoopAdapter does not exist`
whenever a branch was pushed to more than once.
2. The same thing happens with the `integration_test-basic-flow` job
because the `api` service gets built after the `web` service in
docker-compose.yml, overwriting its cache
For some reason it seems the `APPLICATION_NAME` ARG is not busting the
Docker cache properly on GitHub actions for elixir container builds, so
the fix here was to [use
`scope=`](https://docs.docker.com/build/cache/backends/gha/#scope) to
segregate the cache layers between builds of the same branch.
75 lines
1.6 KiB
Docker
75 lines
1.6 KiB
Docker
ARG ALPINE_VERSION=3.18.2
|
|
ARG OTP_VERSION=26.0.2
|
|
ARG ELIXIR_VERSION=1.15.2
|
|
|
|
ARG BUILDER_IMAGE="firezone/elixir:${ELIXIR_VERSION}-otp-${OTP_VERSION}"
|
|
ARG RUNNER_IMAGE="alpine:${ALPINE_VERSION}"
|
|
|
|
FROM ${BUILDER_IMAGE} as builder
|
|
|
|
# install build dependencies
|
|
RUN apk add nodejs npm build-base git python3
|
|
|
|
# Add pnpm
|
|
RUN npm i -g pnpm
|
|
|
|
# prepare build dir
|
|
WORKDIR /app
|
|
|
|
# install hex + rebar
|
|
RUN mix local.hex --force && \
|
|
mix local.rebar --force
|
|
|
|
# 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
|
|
|
|
ARG APPLICATION_VERSION=0.0.0-dev.docker
|
|
|
|
# Install pipeline and compile assets for Web app
|
|
RUN cd apps/web \
|
|
&& mix assets.setup \
|
|
&& mix assets.deploy
|
|
|
|
# Compile the release
|
|
RUN mix compile
|
|
|
|
COPY rel rel
|
|
|
|
ARG APPLICATION_NAME
|
|
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}
|
|
|
|
RUN apk add -u --no-cache libstdc++ ncurses-libs openssl curl
|
|
|
|
WORKDIR /app
|
|
|
|
ARG MIX_ENV="prod"
|
|
|
|
ARG APPLICATION_NAME
|
|
ARG APPLICATION_VERSION=0.0.0-dev.docker
|
|
|
|
ENV APPLICATION_NAME=$APPLICATION_NAME
|
|
ENV APPLICATION_VERSION=$APPLICATION_VERSION
|
|
|
|
# Only copy the final release from the build stage
|
|
COPY --from=builder /app/_build/${MIX_ENV}/rel/${APPLICATION_NAME} ./
|
|
|
|
# Change user to "default" to limit runtime privileges
|
|
# USER default
|
|
|
|
CMD bin/server
|