pleroma-docker/Dockerfile

97 lines
2.6 KiB
Docker
Raw Permalink Normal View History

2022-06-08 13:22:05 +00:00
FROM alpine:3.16
2019-08-25 16:44:49 +00:00
ARG __VIA_SCRIPT
RUN \
if [ -z "$__VIA_SCRIPT" ]; then \
echo -e "\n\nERROR\nYou must build pleroma via build.sh\n\n"; \
exit 1; \
fi
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 LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
2019-08-25 21:29:34 +00:00
ARG MIX_ENV
ENV MIX_ENV=$MIX_ENV
2018-08-20 21:06:47 +00:00
# Prepare mounts
2019-08-25 22:28:14 +00:00
VOLUME /custom.d /uploads
2018-12-28 00:44:33 +00:00
2019-08-25 21:32:13 +00:00
# Expose HTTP, Gopher, and SSH ports, respectively
EXPOSE 4000 9999 2222
2018-12-28 00:44:33 +00:00
# Get dependencies
2018-08-20 21:06:34 +00:00
RUN \
apk add --no-cache --virtual .tools \
2019-01-10 18:49:47 +00:00
git curl rsync postgresql-client \
2019-08-25 21:29:34 +00:00
&& \
apk add --no-cache --virtual .sdk \
2021-01-28 00:30:33 +00:00
build-base cmake file-dev \
2019-08-25 21:29:34 +00:00
&& \
apk add --no-cache --virtual .runtime \
2021-08-13 08:56:12 +00:00
imagemagick ffmpeg exiftool \
2021-01-28 00:30:33 +00:00
elixir erlang erlang-dev
2018-08-20 21:06:34 +00:00
# Add entrypoint
COPY ./entrypoint.sh /
RUN chmod a+x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
2018-08-20 21:06:47 +00:00
# Limit permissions
2019-08-25 21:29:34 +00:00
ARG DOCKER_UID
ARG DOCKER_GID
2018-08-20 21:06:34 +00:00
RUN \
2019-08-25 21:29:34 +00:00
echo "#> Pleroma user will be ${DOCKER_UID}:${DOCKER_GID}" 1>&2 && \
addgroup -g ${DOCKER_GID} pleroma && \
adduser -S -s /bin/ash -G pleroma -u ${DOCKER_UID} pleroma && \
mkdir -p /custom.d /uploads && \
chown -R pleroma:pleroma /custom.d /uploads
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
2020-09-07 17:12:09 +00:00
#
# Also make sure that instance/static/emoji exists.
# Pleroma does not ship with an `instance` folder by default, causing docker to create `instance/static` for us at launch.
# In itself that wouldn't be much of an issue, but said folder(s) are created as root:pleroma with 2755.
# This breaks the custom.d step in entrypoint.sh which relies on writing there (See #10).
#
2019-08-25 21:29:34 +00:00
ARG PLEROMA_GIT_REPO
RUN \
echo "#> Getting pleroma sources from $PLEROMA_GIT_REPO..." 1>&2 && \
2020-09-07 17:12:09 +00:00
git clone --progress $PLEROMA_GIT_REPO ./pleroma && \
mkdir -p ./pleroma/instance/static/emoji
2019-08-25 21:29:34 +00:00
2018-08-20 21:06:47 +00:00
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
2019-08-25 16:44:49 +00:00
# used version/branch/tag/commit/... which originates in the script.
2019-01-10 17:24:29 +00:00
ARG __CACHE_TAG
ENV __CACHE_TAG $__CACHE_TAG
2018-12-28 00:44:33 +00:00
2018-08-20 21:06:34 +00:00
# Fetch changes, checkout
# Only pull if the version-string happens to be a branch
2018-08-20 21:06:47 +00:00
ARG PLEROMA_VERSION
2018-08-20 21:06:34 +00:00
RUN \
2019-08-25 21:29:34 +00:00
git fetch --all && \
git checkout $PLEROMA_VERSION && \
if git show-ref --quiet "refs/heads/$PLEROMA_VERSION"; then \
git pull --rebase --autostash; \
fi
2018-04-09 09:55:52 +00:00
2018-12-20 01:44:16 +00:00
# Precompile
RUN \
2019-08-25 21:29:34 +00:00
cp ./config/dev.exs ./config/prod.secret.exs && \
BUILDTIME=1 /entrypoint.sh && \
rm ./config/prod.secret.exs
2019-09-05 01:48:34 +00:00
# Register healthcheck
# You might need to change these values on slow or busy servers.
HEALTHCHECK \
--interval=10s \
--start-period=50s \
--timeout=4s \
--retries=3 \
CMD curl -sSLf http://localhost:4000/api/pleroma/healthcheck || exit 1