2020-05-26 16:09:34 +03:00
|
|
|
# we can not use the pre-built tar because the distribution is
|
|
|
|
# platform specific, it makes sense to build it in the docker
|
|
|
|
|
|
|
|
#### Builder
|
2022-05-02 15:58:07 +03:00
|
|
|
FROM hexpm/elixir:1.13.4-erlang-24.3.3-alpine-3.15.3 as buildcontainer
|
2020-05-26 16:09:34 +03:00
|
|
|
|
|
|
|
# preparation
|
|
|
|
ENV MIX_ENV=prod
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
|
|
|
|
RUN mkdir /app
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
# install build dependencies
|
2021-01-13 11:31:16 +03:00
|
|
|
RUN apk add --no-cache git nodejs yarn python3 npm ca-certificates wget gnupg make erlang gcc libc-dev && \
|
2022-05-27 15:24:11 +03:00
|
|
|
npm install npm@latest -g && \
|
|
|
|
npm install -g webpack
|
2020-05-26 16:09:34 +03:00
|
|
|
|
2021-12-29 12:58:22 +03:00
|
|
|
RUN wget https://s3.eu-central-1.wasabisys.com/plausible-application/geonames.csv -q
|
|
|
|
|
2020-05-26 16:09:34 +03:00
|
|
|
COPY mix.exs ./
|
|
|
|
COPY mix.lock ./
|
2022-09-21 14:42:22 +03:00
|
|
|
COPY config ./config
|
2020-05-26 16:09:34 +03:00
|
|
|
RUN mix local.hex --force && \
|
2022-05-27 15:24:11 +03:00
|
|
|
mix local.rebar --force && \
|
|
|
|
mix deps.get --only prod && \
|
|
|
|
mix deps.compile
|
2020-05-26 16:09:34 +03:00
|
|
|
|
2020-10-05 15:01:54 +03:00
|
|
|
COPY assets/package.json assets/package-lock.json ./assets/
|
|
|
|
COPY tracker/package.json tracker/package-lock.json ./tracker/
|
|
|
|
|
2021-05-12 13:07:55 +03:00
|
|
|
RUN npm install --prefix ./assets && \
|
2022-05-27 15:24:11 +03:00
|
|
|
npm install --prefix ./tracker
|
2020-10-05 15:01:54 +03:00
|
|
|
|
|
|
|
COPY assets ./assets
|
|
|
|
COPY tracker ./tracker
|
|
|
|
COPY priv ./priv
|
|
|
|
COPY lib ./lib
|
|
|
|
|
|
|
|
RUN npm run deploy --prefix ./assets && \
|
2022-05-27 15:24:11 +03:00
|
|
|
npm run deploy --prefix ./tracker && \
|
|
|
|
mix phx.digest priv/static && \
|
|
|
|
mix download_country_database && \
|
|
|
|
# https://hexdocs.pm/sentry/Sentry.Sources.html#module-source-code-storage
|
|
|
|
mix sentry_recompile && \
|
|
|
|
mv geonames.csv ./priv/geonames.csv
|
2020-05-26 16:09:34 +03:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
COPY rel rel
|
|
|
|
RUN mix release plausible
|
|
|
|
|
|
|
|
# Main Docker Image
|
2022-05-02 15:58:07 +03:00
|
|
|
FROM alpine:3.15.3
|
2020-05-26 16:09:34 +03:00
|
|
|
LABEL maintainer="tckb <tckb@tgrthi.me>"
|
2022-05-27 15:24:11 +03:00
|
|
|
|
|
|
|
ARG BUILD_METADATA={}
|
|
|
|
ENV BUILD_METADATA=$BUILD_METADATA
|
2020-05-26 16:09:34 +03:00
|
|
|
ENV LANG=C.UTF-8
|
|
|
|
|
2021-11-04 15:17:40 +03:00
|
|
|
RUN apk upgrade --no-cache
|
2021-01-13 11:31:16 +03:00
|
|
|
|
2021-09-09 12:14:53 +03:00
|
|
|
RUN apk add --no-cache openssl ncurses libstdc++ libgcc
|
2020-05-26 16:09:34 +03:00
|
|
|
|
2022-09-13 14:28:28 +03:00
|
|
|
COPY ./rel/docker-entrypoint.sh /entrypoint.sh
|
2020-05-26 16:09:34 +03:00
|
|
|
|
|
|
|
RUN chmod a+x /entrypoint.sh && \
|
2022-05-27 15:24:11 +03:00
|
|
|
adduser -h /app -u 1000 -s /bin/sh -D plausibleuser
|
2020-05-26 16:09:34 +03:00
|
|
|
|
|
|
|
COPY --from=buildcontainer /app/_build/prod/rel/plausible /app
|
|
|
|
RUN chown -R plausibleuser:plausibleuser /app
|
2020-10-15 11:22:04 +03:00
|
|
|
USER plausibleuser
|
2020-05-26 16:09:34 +03:00
|
|
|
WORKDIR /app
|
2021-12-29 12:58:22 +03:00
|
|
|
ENV GEONAMES_SOURCE_FILE=/app/lib/plausible-0.0.1/priv/geonames.csv
|
2022-01-21 23:23:09 +03:00
|
|
|
ENV LISTEN_IP=0.0.0.0
|
2020-05-26 16:09:34 +03:00
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
2021-02-05 12:27:44 +03:00
|
|
|
EXPOSE 8000
|
2020-05-26 16:09:34 +03:00
|
|
|
CMD ["run"]
|