-
-
Save ZoomQuiet/23a3b2a67f065dbda1a339e953de15bd to your computer and use it in GitHub Desktop.
Elixir Umbrella App Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM elixir:1.11.1-alpine AS build | |
# install build dependencies | |
RUN apk add --no-cache build-base npm git | |
# prepare build dir | |
WORKDIR /app | |
# install hex + rebar | |
RUN mix local.hex --force && \ | |
mix local.rebar --force | |
# set build ENV | |
ENV MIX_ENV=prod | |
# copy umbrella apps | |
COPY apps/my_app apps/my_app | |
COPY apps/my_app_web/lib apps/my_app_web/priv apps/my_app_web/test apps/my_app_web/mix.exs apps/my_app_web/ | |
# install mix dependencies | |
COPY mix.exs mix.lock ./ | |
COPY config config | |
RUN mix do deps.get, deps.compile | |
# build assets | |
COPY apps/my_app_web/assets/package.json apps/my_app_web/assets/package-lock.json ./apps/my_app_web/assets/ | |
RUN npm --prefix ./apps/my_app_web/assets ci --progress=false --no-audit --loglevel=error | |
COPY apps/my_app_web/priv apps/my_app_web/assets apps/my_app_web/assets/ | |
RUN npm run --prefix ./apps/my_app_web/assets deploy | |
RUN mix phx.digest | |
# compile and build release | |
COPY . . | |
RUN mix do compile, release | |
# prepare release image | |
FROM alpine:3.9 AS app | |
RUN apk add --no-cache openssl ncurses-libs | |
WORKDIR /app | |
RUN chown nobody:nobody /app | |
USER nobody:nobody | |
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/my_app_web ./ | |
ENV HOME=/app | |
CMD ["bin/my_app_web", "start"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment