pleroma-docker/Dockerfile

84 lines
2.2 KiB
Docker
Raw Normal View History

2018-08-20 21:06:47 +00:00
FROM debian:9-slim
2018-04-07 20:29:55 +00:00
2018-12-28 00:44:33 +00:00
# Set up environment
2018-08-20 21:06:47 +00:00
ENV DEBIAN_FRONTEND=noninteractive
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
2018-12-28 00:44:33 +00:00
# Prepare mounts and entrypoint
VOLUME /custom.d
VOLUME /conf
COPY ./entrypoint.sh /
2018-08-20 21:06:47 +00:00
RUN chmod a+x /entrypoint.sh
2018-12-24 22:21:16 +00:00
ENTRYPOINT ["/entrypoint.sh"]
2018-08-20 21:06:34 +00:00
2018-12-28 00:44:33 +00:00
# Expose default pleroma port to host
EXPOSE 4000
# Get erlang, elixir, and dependencies
2018-08-20 21:06:34 +00:00
RUN \
apt-get update \
2018-12-20 01:44:16 +00:00
&& apt-get install -y --no-install-recommends apt-utils \
2018-12-28 00:44:33 +00:00
&& apt-get install -y --no-install-recommends git wget ca-certificates gnupg2 build-essential ruby \
2018-12-20 01:44:16 +00:00
\
2018-08-20 21:06:47 +00:00
&& wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb \
&& dpkg -i erlang-solutions_1.0_all.deb \
&& apt-get update \
&& apt-get install -y --no-install-recommends esl-erlang elixir \
2018-12-20 01:44:16 +00:00
\
2018-08-20 21:06:34 +00:00
&& rm -rf /var/lib/apt/lists/*
2018-08-20 21:06:47 +00:00
# Limit permissions
2018-12-28 00:44:33 +00:00
ARG DOCKER_UID=1000
ARG DOCKER_GID=1000
ARG PLEROMA_UPLOADS_PATH=/uploads
2018-08-20 21:06:34 +00:00
RUN \
2018-08-20 21:06:47 +00:00
groupadd --gid ${DOCKER_GID} pleroma \
&& useradd -m -s /bin/bash --gid ${DOCKER_GID} --uid ${DOCKER_UID} pleroma \
&& mkdir -p /custom.d $PLEROMA_UPLOADS_PATH \
2018-12-28 00:44:33 +00:00
&& chown -R pleroma:pleroma /custom.d /conf $PLEROMA_UPLOADS_PATH
2018-08-20 21:06:34 +00:00
USER pleroma
2018-08-20 21:06:47 +00:00
WORKDIR /home/pleroma
2018-08-20 21:06:34 +00:00
2018-12-28 00:44:33 +00:00
# Get pleroma sources
2018-08-20 21:06:47 +00:00
RUN git clone --progress https://git.pleroma.social/pleroma/pleroma.git ./pleroma
WORKDIR /home/pleroma/pleroma
2018-04-09 09:55:52 +00:00
2018-12-28 00:44:33 +00:00
# Bust the build cache (if needed)
# This works by setting an environment variable with the last
# used version/branch/tag/commitish/... which originates in the script.
# If the host doesn't have the required tool for "smart version detection"
# we'll just use the current timestamp here which forces a rebuild every time.
ARG __BUST_CACHE
ENV __BUST_CACHE $__BUST_CACHE
# Get rebar and hex
2018-04-09 09:55:52 +00:00
RUN \
2018-08-21 01:19:42 +00:00
mix local.hex --force \
2018-08-20 21:06:34 +00:00
&& mix local.rebar --force
2018-04-08 14:15:44 +00:00
2018-08-20 21:06:34 +00:00
# Fetch changes, checkout
2018-08-20 21:06:47 +00:00
ARG PLEROMA_VERSION
2018-08-20 21:06:34 +00:00
RUN \
git fetch --all \
&& git checkout $PLEROMA_VERSION \
&& git pull --rebase --autostash
2018-04-09 09:55:52 +00:00
2018-12-20 01:44:16 +00:00
# Precompile
RUN \
mix deps.get \
&& mix compile
2018-12-28 00:44:33 +00:00
# Prepare runtime config
2018-08-20 21:06:34 +00:00
RUN \
2018-12-28 00:44:33 +00:00
ln -sf runtime-config.exs config/prod.secret.exs \
&& ln -sf runtime-config.exs config/dev.secret.exs
# Insert overrides
COPY --chown=pleroma:pleroma ./custom.d /home/pleroma/pleroma
# Recompiles at runtime if custom.d contained elixir code.