Files
firezone/elixir/Dockerfile
Andrew Dryga d9eb2d18df Deployment for the cloud version (#1638)
TODO:
- [x] Cluster formation for all API and web nodes
- [x] Injest Docker logs to Stackdriver
- [x] Fix assets building for prod

To finish later:
- [ ] Structured logging:
https://issuetracker.google.com/issues/285950891
- [ ] Better networking policy (eg. use public postmark ranges and deny
all unwanted egress)
- [ ] OpenTelemetry collector for Google Stackdriver
- [ ] LoggerJSON.Plug integration

---------

Signed-off-by: Andrew Dryga <andrew@dryga.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
2023-06-06 15:03:26 -06:00

73 lines
1.6 KiB
Docker

ARG ELIXIR_VERSION=1.14.3
ARG OTP_VERSION=25.2.1
ARG ALPINE_VERSION=3.16.3
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 yarn build-base git python3
# 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 \
&& cd ../../
# 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