mobilizon/docker/production/Dockerfile

64 lines
1.7 KiB
Docker
Raw Normal View History

2020-10-22 15:19:01 +02:00
# First build the application assets
FROM node:14-alpine as assets
2020-10-22 15:19:01 +02: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 \
&& yarn run build
2020-10-22 15:19:01 +02:00
# Then, build the application binary
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 ./
ENV MIX_ENV=prod
2020-10-22 15:19:01 +02:00
RUN mix local.hex --force \
&& mix local.rebar --force \
&& mix deps.get
2020-10-22 15:19:01 +02:00
COPY lib ./lib
COPY priv ./priv
COPY config/config.exs config/prod.exs ./config/
COPY config/docker.exs ./config/runtime.exs
COPY rel ./rel
COPY support ./support
2020-10-22 15:19:01 +02:00
COPY --from=assets ./priv/static ./priv/static
RUN mix phx.digest \
&& mix release
2020-10-22 15:19:01 +02:00
# Finally setup the app
FROM alpine
ARG BUILD_DATE
ARG VCS_REF
ARG CI_COMMIT_TAG
ARG MOBILIZON_VERSION=${CI_COMMIT_TAG}
LABEL org.opencontainers.image.title="mobilizon" \
org.opencontainers.image.description="Mobilizon for Docker" \
org.opencontainers.image.vendor="joinmobilizon.org" \
org.opencontainers.image.documentation="https://docs.joinmobilizon.org" \
org.opencontainers.image.licenses="AGPL-3.0" \
org.opencontainers.image.url="https://joinmobilizon.org" \
org.opencontainers.image.revision=$VCS_REF \
org.opencontainers.image.created=$BUILD_DATE
RUN apk add --no-cache openssl ncurses-libs file postgresql-client
2020-10-22 15:19:01 +02:00
RUN mkdir -p /app/uploads && chown nobody:nobody /app/uploads
RUN mkdir -p /etc/mobilizon && chown nobody:nobody /etc/mobilizon
2020-10-22 15:19:01 +02:00
USER nobody
EXPOSE 4000
ENV MOBILIZON_DOCKER=true
2020-10-22 15:19:01 +02:00
COPY --from=builder --chown=nobody:nobody _build/prod/rel/mobilizon ./
RUN cp /releases/${MOBILIZON_VERSION}/runtime.exs /etc/mobilizon/config.exs
COPY docker/production/docker-entrypoint.sh ./
2020-10-22 15:19:01 +02:00
ENTRYPOINT ["./docker-entrypoint.sh"]