2020-10-22 13:19:01 +00:00
|
|
|
# First build the application assets
|
2023-05-22 16:44:21 +00:00
|
|
|
FROM node:18-alpine as assets
|
2020-10-22 13:19:01 +00:00
|
|
|
|
2022-10-12 12:31:07 +00:00
|
|
|
RUN apk add --no-cache python3 build-base libwebp-tools bash imagemagick ncurses
|
2021-06-16 15:08:49 +00:00
|
|
|
WORKDIR /build
|
2023-11-14 16:24:42 +00:00
|
|
|
COPY . .
|
2021-10-25 14:53:05 +00:00
|
|
|
|
2021-11-09 09:39:04 +00:00
|
|
|
# Network timeout because it's slow when cross-compiling
|
2023-11-14 16:24:42 +00:00
|
|
|
RUN npm install && npm run build
|
2020-10-22 13:19:01 +00:00
|
|
|
|
|
|
|
# Then, build the application binary
|
2023-09-05 17:44:26 +00:00
|
|
|
FROM elixir:1.15-alpine AS builder
|
2020-10-22 13:19:01 +00:00
|
|
|
|
2023-08-18 14:22:19 +00:00
|
|
|
# Fix qemu segfault on arm64
|
|
|
|
# See https://github.com/plausible/analytics/pull/2879 and https://github.com/erlang/otp/pull/6340
|
|
|
|
ARG ERL_FLAGS=""
|
|
|
|
ENV ERL_FLAGS=$ERL_FLAGS
|
|
|
|
|
2022-10-12 12:31:07 +00:00
|
|
|
RUN apk add --no-cache build-base git cmake
|
2020-10-22 13:19:01 +00:00
|
|
|
|
|
|
|
COPY mix.exs mix.lock ./
|
2020-10-18 23:01:59 +00:00
|
|
|
ENV MIX_ENV=prod
|
2020-10-22 13:19:01 +00:00
|
|
|
RUN mix local.hex --force \
|
2020-10-30 14:16:33 +00:00
|
|
|
&& mix local.rebar --force \
|
2022-04-18 12:54:00 +00:00
|
|
|
&& mix deps.get
|
2020-10-18 23:01:59 +00:00
|
|
|
|
2020-10-22 13:19:01 +00:00
|
|
|
COPY lib ./lib
|
|
|
|
COPY priv ./priv
|
2021-03-15 13:57:08 +00:00
|
|
|
COPY config/config.exs config/prod.exs ./config/
|
|
|
|
COPY config/docker.exs ./config/runtime.exs
|
2020-10-31 01:39:32 +00:00
|
|
|
COPY rel ./rel
|
2021-04-22 15:28:03 +00:00
|
|
|
COPY support ./support
|
2023-11-21 15:32:55 +00:00
|
|
|
COPY --from=assets /build/priv/static ./priv/static
|
2020-10-22 13:19:01 +00:00
|
|
|
|
2022-10-17 06:37:22 +00:00
|
|
|
RUN mix phx.digest.clean --all && mix phx.digest && mix release
|
2020-10-22 13:19:01 +00:00
|
|
|
|
|
|
|
# Finally setup the app
|
2022-10-12 12:31:07 +00:00
|
|
|
FROM alpine
|
2020-10-22 13:19:01 +00:00
|
|
|
|
2021-02-01 13:57:58 +00:00
|
|
|
ARG BUILD_DATE
|
|
|
|
ARG VCS_REF
|
|
|
|
|
|
|
|
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" \
|
2021-04-23 17:12:42 +00:00
|
|
|
org.opencontainers.image.source="https://framagit.org/framasoft/mobilizon" \
|
2021-02-01 13:57:58 +00:00
|
|
|
org.opencontainers.image.url="https://joinmobilizon.org" \
|
|
|
|
org.opencontainers.image.revision=$VCS_REF \
|
|
|
|
org.opencontainers.image.created=$BUILD_DATE
|
|
|
|
|
2022-12-22 17:10:26 +00:00
|
|
|
RUN apk add --no-cache curl openssl ca-certificates ncurses-libs file postgresql-client libgcc libstdc++ imagemagick python3 py3-pip py3-pillow py3-cffi py3-brotli gcc g++ musl-dev python3-dev pango libxslt-dev ttf-cantarell openssl1.1-compat
|
2021-11-08 11:15:02 +00:00
|
|
|
RUN pip install weasyprint pyexcel-ods3
|
2020-10-22 13:19:01 +00:00
|
|
|
|
2023-05-22 16:44:21 +00:00
|
|
|
# Create every data directory
|
2022-10-12 12:31:07 +00:00
|
|
|
RUN mkdir -p /var/lib/mobilizon/uploads && chown nobody:nobody /var/lib/mobilizon/uploads
|
2023-05-22 16:44:21 +00:00
|
|
|
RUN mkdir -p /var/lib/mobilizon/timezones && chown nobody:nobody /var/lib/mobilizon/timezones
|
|
|
|
RUN mkdir -p /var/lib/mobilizon/tzdata && chown nobody:nobody /var/lib/mobilizon/tzdata
|
2023-09-18 12:43:21 +00:00
|
|
|
RUN mkdir -p /var/lib/mobilizon/sitemap && chown nobody:nobody /var/lib/mobilizon/sitemap
|
2022-10-12 12:31:07 +00:00
|
|
|
RUN mkdir -p /var/lib/mobilizon/uploads/exports/{csv,pdf,ods} && chown -R nobody:nobody /var/lib/mobilizon/uploads/exports
|
2023-05-22 16:44:21 +00:00
|
|
|
|
|
|
|
# Get timezone geodata
|
2021-11-29 08:56:48 +00:00
|
|
|
RUN curl -L 'https://packages.joinmobilizon.org/tz_world/timezones-geodata.dets' -o /var/lib/mobilizon/timezones/timezones-geodata.dets
|
2023-05-22 16:44:21 +00:00
|
|
|
RUN chown -R nobody:nobody /var/lib/mobilizon/timezones
|
|
|
|
|
|
|
|
# Create configuration directory
|
2022-10-12 12:31:07 +00:00
|
|
|
RUN mkdir -p /etc/mobilizon && chown nobody:nobody /etc/mobilizon
|
2020-11-16 22:28:29 +00:00
|
|
|
|
2020-10-22 13:19:01 +00:00
|
|
|
USER nobody
|
2020-10-18 23:01:59 +00:00
|
|
|
EXPOSE 4000
|
|
|
|
|
2021-02-01 13:57:58 +00:00
|
|
|
ENV MOBILIZON_DOCKER=true
|
|
|
|
|
2022-10-12 12:31:07 +00:00
|
|
|
COPY --from=builder --chown=nobody:nobody _build/prod/rel/mobilizon ./
|
2021-04-23 17:12:52 +00:00
|
|
|
RUN cp /releases/*/runtime.exs /etc/mobilizon/config.exs
|
2020-10-30 14:16:33 +00:00
|
|
|
COPY docker/production/docker-entrypoint.sh ./
|
2020-10-22 13:19:01 +00:00
|
|
|
|
2020-10-30 14:16:33 +00:00
|
|
|
ENTRYPOINT ["./docker-entrypoint.sh"]
|