2022-04-19 20:12:28 -04:00
|
|
|
FROM elixir:1.13.4-alpine AS build
|
2021-09-04 16:14:51 -04:00
|
|
|
|
|
|
|
# install build dependencies
|
|
|
|
RUN apk add --no-cache build-base npm git python3
|
|
|
|
|
|
|
|
# prepare build dir
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# install hex + rebar
|
|
|
|
RUN mix local.hex --force && \
|
|
|
|
mix local.rebar --force
|
|
|
|
|
|
|
|
# set build ENV
|
|
|
|
ENV MIX_ENV=prod
|
|
|
|
|
|
|
|
# install mix dependencies
|
|
|
|
COPY mix.exs mix.lock ./
|
|
|
|
COPY config config
|
|
|
|
RUN mix do deps.get, deps.compile
|
|
|
|
|
|
|
|
# build assets
|
|
|
|
COPY assets/package.json assets/package-lock.json ./assets/
|
|
|
|
RUN npm --prefix ./assets ci --progress=false --no-audit --loglevel=error
|
|
|
|
|
|
|
|
COPY lib lib
|
|
|
|
COPY priv priv
|
|
|
|
COPY assets assets
|
|
|
|
RUN npm run --prefix ./assets deploy
|
2022-02-13 15:50:59 -05:00
|
|
|
RUN mix do phx.digest, gettext.extract
|
2021-09-04 16:14:51 -04:00
|
|
|
|
|
|
|
# compile and build release
|
|
|
|
# uncomment COPY if rel/ exists
|
|
|
|
# COPY rel rel
|
|
|
|
RUN mix do compile, release
|
|
|
|
|
|
|
|
# prepare release image
|
2022-02-18 17:44:58 -05:00
|
|
|
FROM alpine:latest AS app
|
2021-09-04 16:14:51 -04:00
|
|
|
|
|
|
|
RUN apk upgrade --no-cache && \
|
|
|
|
apk add --no-cache bash openssl libgcc libstdc++ ncurses-libs
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
RUN chown nobody:nobody /app
|
|
|
|
|
|
|
|
USER nobody:nobody
|
|
|
|
|
|
|
|
COPY --from=build --chown=nobody:nobody /app/_build/prod/rel/cannery ./
|
|
|
|
COPY --from=build --chown=nobody:nobody /app/priv /app/priv
|
2022-02-17 23:41:31 -05:00
|
|
|
RUN chmod +x /app/priv/random.sh
|
2021-09-04 16:14:51 -04:00
|
|
|
|
|
|
|
ENV HOME=/app
|
|
|
|
|
2022-02-13 15:50:59 -05:00
|
|
|
CMD ["bin/cannery", "start"]
|