2020-10-22 15:19:01 +02:00
|
|
|
# First build the application assets
|
2021-02-04 18:58:15 +01:00
|
|
|
FROM node:14-alpine as assets
|
2020-10-22 15:19:01 +02:00
|
|
|
|
2020-12-13 14:38:04 +01:00
|
|
|
RUN apk add --no-cache python build-base libwebp-tools bash imagemagick ncurses
|
2020-10-22 15:19:01 +02:00
|
|
|
|
|
|
|
COPY js .
|
|
|
|
RUN yarn install \
|
2020-10-30 15:16:33 +01:00
|
|
|
&& yarn run build
|
2020-10-22 15:19:01 +02:00
|
|
|
|
|
|
|
# Then, build the application binary
|
2021-02-04 18:58:15 +01:00
|
|
|
FROM elixir:1.11-alpine AS builder
|
2020-10-22 15:19:01 +02:00
|
|
|
|
|
|
|
RUN apk add --no-cache build-base git cmake
|
|
|
|
|
|
|
|
COPY mix.exs mix.lock ./
|
2020-10-19 01:01:59 +02:00
|
|
|
ENV MIX_ENV=prod
|
2020-10-22 15:19:01 +02:00
|
|
|
RUN mix local.hex --force \
|
2020-10-30 15:16:33 +01:00
|
|
|
&& mix local.rebar --force \
|
|
|
|
&& mix deps.get
|
2020-10-19 01:01:59 +02:00
|
|
|
|
2020-10-22 15:19:01 +02:00
|
|
|
COPY lib ./lib
|
|
|
|
COPY priv ./priv
|
|
|
|
COPY config ./config
|
2020-10-31 02:39:32 +01:00
|
|
|
COPY rel ./rel
|
2020-10-22 15:19:01 +02:00
|
|
|
COPY docker/production/releases.exs ./config/
|
|
|
|
COPY --from=assets ./priv/static ./priv/static
|
|
|
|
|
|
|
|
RUN mix phx.digest \
|
2020-10-30 15:16:33 +01:00
|
|
|
&& mix release
|
2020-10-22 15:19:01 +02:00
|
|
|
|
|
|
|
# Finally setup the app
|
|
|
|
FROM alpine
|
|
|
|
|
2020-11-14 19:31:23 +01:00
|
|
|
RUN apk add --no-cache openssl ncurses-libs file postgresql-client
|
2020-10-22 15:19:01 +02:00
|
|
|
|
2020-11-16 23:28:29 +01:00
|
|
|
RUN mkdir -p /app/uploads && chown nobody:nobody /app/uploads
|
|
|
|
|
2020-10-22 15:19:01 +02:00
|
|
|
USER nobody
|
2020-10-19 01:01:59 +02:00
|
|
|
EXPOSE 4000
|
|
|
|
|
2020-10-22 15:19:01 +02:00
|
|
|
COPY --from=builder --chown=nobody:nobody _build/prod/rel/mobilizon ./
|
2020-10-30 15:16:33 +01:00
|
|
|
COPY docker/production/docker-entrypoint.sh ./
|
2020-10-22 15:19:01 +02:00
|
|
|
|
2020-10-30 15:16:33 +01:00
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|