2022-11-17 11:01:16 +01:00
|
|
|
# syntax=docker/dockerfile:1.4
|
2023-09-05 18:19:59 +02:00
|
|
|
# This needs to be bookworm-slim because the Ruby image is built on bookworm-slim
|
2023-11-06 11:27:42 +01:00
|
|
|
ARG NODE_VERSION="20.9-bookworm-slim"
|
2019-02-24 16:32:40 +01:00
|
|
|
|
2023-03-31 18:28:40 +02:00
|
|
|
FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.2-slim as ruby
|
2022-11-17 12:56:14 +01:00
|
|
|
FROM node:${NODE_VERSION} as build
|
2019-02-24 16:32:40 +01:00
|
|
|
|
2022-11-17 12:56:14 +01:00
|
|
|
COPY --link --from=ruby /opt/ruby /opt/ruby
|
2019-02-24 16:32:40 +01:00
|
|
|
|
2022-11-17 12:56:14 +01:00
|
|
|
ENV DEBIAN_FRONTEND="noninteractive" \
|
|
|
|
PATH="${PATH}:/opt/ruby/bin"
|
2019-02-24 16:32:40 +01:00
|
|
|
|
2022-11-17 12:56:14 +01:00
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
|
|
|
|
|
|
WORKDIR /opt/mastodon
|
2019-02-24 16:32:40 +01:00
|
|
|
|
2022-12-15 15:57:17 +01:00
|
|
|
# hadolint ignore=DL3008
|
|
|
|
RUN apt-get update && \
|
2023-09-14 23:11:36 +02:00
|
|
|
apt-get -yq dist-upgrade && \
|
2022-11-17 12:56:14 +01:00
|
|
|
apt-get install -y --no-install-recommends build-essential \
|
|
|
|
git \
|
|
|
|
libicu-dev \
|
2023-09-05 18:19:59 +02:00
|
|
|
libidn-dev \
|
2022-11-17 12:56:14 +01:00
|
|
|
libpq-dev \
|
|
|
|
libjemalloc-dev \
|
|
|
|
zlib1g-dev \
|
|
|
|
libgdbm-dev \
|
|
|
|
libgmp-dev \
|
|
|
|
libssl-dev \
|
2023-10-24 19:32:10 +02:00
|
|
|
libyaml-dev \
|
2022-11-17 12:56:14 +01:00
|
|
|
ca-certificates \
|
|
|
|
libreadline8 \
|
|
|
|
python3 \
|
|
|
|
shared-mime-info && \
|
|
|
|
bundle config set --local deployment 'true' && \
|
|
|
|
bundle config set --local without 'development test' && \
|
|
|
|
bundle config set silence_root_warning true && \
|
2023-11-08 11:57:21 +01:00
|
|
|
corepack enable
|
|
|
|
|
|
|
|
COPY Gemfile* package.json yarn.lock .yarnrc.yml /opt/mastodon/
|
2023-11-18 11:14:51 +01:00
|
|
|
COPY streaming/package.json /opt/mastodon/streaming/
|
2023-11-08 11:57:21 +01:00
|
|
|
COPY .yarn /opt/mastodon/.yarn
|
|
|
|
|
|
|
|
RUN bundle install -j"$(nproc)"
|
|
|
|
|
|
|
|
RUN yarn workspaces focus --all --production && \
|
2023-02-13 04:57:51 +01:00
|
|
|
yarn cache clean
|
2022-11-17 12:56:14 +01:00
|
|
|
|
|
|
|
FROM node:${NODE_VERSION}
|
|
|
|
|
2023-05-04 21:33:32 +02:00
|
|
|
# Use those args to specify your own version flags & suffixes
|
2023-08-25 18:26:44 +02:00
|
|
|
ARG MASTODON_VERSION_PRERELEASE=""
|
|
|
|
ARG MASTODON_VERSION_METADATA=""
|
2023-05-04 21:33:32 +02:00
|
|
|
|
2022-11-17 12:56:14 +01:00
|
|
|
ARG UID="991"
|
|
|
|
ARG GID="991"
|
|
|
|
|
|
|
|
COPY --link --from=ruby /opt/ruby /opt/ruby
|
2019-02-24 16:32:40 +01:00
|
|
|
|
2021-03-20 21:21:57 +01:00
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
2022-11-17 12:56:14 +01:00
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND="noninteractive" \
|
|
|
|
PATH="${PATH}:/opt/ruby/bin:/opt/mastodon/bin"
|
|
|
|
|
2023-05-19 17:13:29 +02:00
|
|
|
# Ignoring these here since we don't want to pin any versions and the Debian image removes apt-get content after use
|
2022-12-15 15:57:17 +01:00
|
|
|
# hadolint ignore=DL3008,DL3009
|
2021-03-20 21:21:57 +01:00
|
|
|
RUN apt-get update && \
|
2022-11-17 12:56:14 +01:00
|
|
|
echo "Etc/UTC" > /etc/localtime && \
|
|
|
|
groupadd -g "${GID}" mastodon && \
|
2022-12-15 15:57:17 +01:00
|
|
|
useradd -l -u "$UID" -g "${GID}" -m -d /opt/mastodon mastodon && \
|
2022-11-17 12:56:14 +01:00
|
|
|
apt-get -y --no-install-recommends install whois \
|
|
|
|
wget \
|
2022-11-22 05:52:18 +01:00
|
|
|
procps \
|
2023-09-05 18:19:59 +02:00
|
|
|
libssl3 \
|
2022-11-17 12:56:14 +01:00
|
|
|
libpq5 \
|
|
|
|
imagemagick \
|
|
|
|
ffmpeg \
|
|
|
|
libjemalloc2 \
|
2023-09-05 18:19:59 +02:00
|
|
|
libicu72 \
|
|
|
|
libidn12 \
|
2022-11-17 12:56:14 +01:00
|
|
|
libyaml-0-2 \
|
|
|
|
file \
|
|
|
|
ca-certificates \
|
|
|
|
tzdata \
|
|
|
|
libreadline8 \
|
|
|
|
tini && \
|
2023-11-08 11:57:21 +01:00
|
|
|
ln -s /opt/mastodon /mastodon && \
|
|
|
|
corepack enable
|
2022-11-17 12:56:14 +01:00
|
|
|
|
|
|
|
# Note: no, cleaning here since Debian does this automatically
|
|
|
|
# See the file /etc/apt/apt.conf.d/docker-clean within the Docker image's filesystem
|
2019-03-08 16:12:48 +01:00
|
|
|
|
2022-11-17 12:56:14 +01:00
|
|
|
COPY --chown=mastodon:mastodon . /opt/mastodon
|
|
|
|
COPY --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon
|
2019-02-24 16:32:40 +01:00
|
|
|
|
2022-11-17 12:56:14 +01:00
|
|
|
ENV RAILS_ENV="production" \
|
|
|
|
NODE_ENV="production" \
|
|
|
|
RAILS_SERVE_STATIC_FILES="true" \
|
2023-05-04 13:45:39 +02:00
|
|
|
BIND="0.0.0.0" \
|
2023-08-25 18:26:44 +02:00
|
|
|
MASTODON_VERSION_PRERELEASE="${MASTODON_VERSION_PRERELEASE}" \
|
|
|
|
MASTODON_VERSION_METADATA="${MASTODON_VERSION_METADATA}"
|
2019-02-24 16:32:40 +01:00
|
|
|
|
|
|
|
# Set the run user
|
2018-02-20 17:25:01 +01:00
|
|
|
USER mastodon
|
2022-11-17 12:56:14 +01:00
|
|
|
WORKDIR /opt/mastodon
|
2018-02-20 17:25:01 +01:00
|
|
|
|
2019-02-24 16:32:40 +01:00
|
|
|
# Precompile assets
|
2023-02-13 04:57:51 +01:00
|
|
|
RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile
|
2018-07-15 01:19:09 +02:00
|
|
|
|
2019-02-24 16:32:40 +01:00
|
|
|
# Set the work dir and the container entry point
|
2021-03-20 21:21:57 +01:00
|
|
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
2019-11-04 12:56:21 +01:00
|
|
|
EXPOSE 3000 4000
|