2022-11-17 10:01:16 +00:00
|
|
|
# syntax=docker/dockerfile:1.4
|
2022-11-17 11:56:14 +00:00
|
|
|
# This needs to be bullseye-slim because the Ruby image is built on bullseye-slim
|
2023-03-17 04:09:27 +00:00
|
|
|
ARG NODE_VERSION="18.15-bullseye-slim"
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2023-02-15 07:30:27 +00:00
|
|
|
FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.1-slim as ruby
|
2023-04-22 07:14:40 +00:00
|
|
|
FROM node:${NODE_VERSION} as build-base
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2022-11-17 11:56:14 +00:00
|
|
|
COPY --link --from=ruby /opt/ruby /opt/ruby
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2022-11-17 11:56:14 +00:00
|
|
|
ENV DEBIAN_FRONTEND="noninteractive" \
|
2023-03-17 04:09:27 +00:00
|
|
|
PATH="${PATH}:/opt/ruby/bin" \
|
|
|
|
NODE_OPTIONS=--openssl-legacy-provider
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2022-11-17 11:56:14 +00:00
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2022-11-17 11:56:14 +00:00
|
|
|
WORKDIR /opt/mastodon
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2022-12-15 14:57:17 +00:00
|
|
|
# hadolint ignore=DL3008
|
2021-03-20 20:21:57 +00:00
|
|
|
RUN apt-get update && \
|
2022-11-17 11:56:14 +00:00
|
|
|
apt-get install -y --no-install-recommends build-essential \
|
|
|
|
ca-certificates \
|
|
|
|
git \
|
|
|
|
libicu-dev \
|
|
|
|
libidn11-dev \
|
|
|
|
libpq-dev \
|
|
|
|
libjemalloc-dev \
|
|
|
|
zlib1g-dev \
|
|
|
|
libgdbm-dev \
|
|
|
|
libgmp-dev \
|
|
|
|
libssl-dev \
|
|
|
|
libyaml-0-2 \
|
|
|
|
ca-certificates \
|
|
|
|
libreadline8 \
|
|
|
|
python3 \
|
2023-03-16 03:48:30 +00:00
|
|
|
shared-mime-info
|
|
|
|
|
|
|
|
COPY --link .yarn/releases/ /opt/mastodon/.yarn/releases/
|
|
|
|
COPY --link Gemfile* package.json yarn.lock .yarnrc.yml /opt/mastodon/
|
|
|
|
|
|
|
|
RUN \
|
2022-11-17 11:56:14 +00:00
|
|
|
bundle config set --local deployment 'true' && \
|
|
|
|
bundle config set --local without 'development test' && \
|
|
|
|
bundle config set silence_root_warning true && \
|
|
|
|
bundle install -j"$(nproc)" && \
|
2023-03-16 03:48:30 +00:00
|
|
|
yarn install --immutable && \
|
2023-02-13 03:57:51 +00:00
|
|
|
yarn cache clean
|
2022-11-17 11:56:14 +00:00
|
|
|
|
2023-03-16 03:48:30 +00:00
|
|
|
# Precompile assets
|
|
|
|
# TODO(kouhai): we're currently patching node_modules because of emoji-mart.
|
|
|
|
# we should integrate our own fork instead.
|
2023-03-17 04:09:27 +00:00
|
|
|
COPY --link . /opt/mastodon
|
2023-04-22 07:14:40 +00:00
|
|
|
|
|
|
|
FROM build-base AS build
|
|
|
|
|
|
|
|
ENV RAILS_ENV="production" \
|
|
|
|
NODE_ENV="production"
|
|
|
|
|
2023-03-16 03:48:30 +00:00
|
|
|
ENV OTP_SECRET=precompile_placeholder \
|
|
|
|
SECRET_KEY_BASE=precompile_placeholder \
|
|
|
|
RAKE_NO_YARN_INSTALL_HACK=1
|
2023-03-17 04:09:27 +00:00
|
|
|
RUN mv ./emoji_data/all.json ./node_modules/emoji-mart/data/all.json && \
|
|
|
|
bundle exec rails assets:precompile
|
2023-03-16 03:48:30 +00:00
|
|
|
|
|
|
|
|
2022-11-17 11:56:14 +00:00
|
|
|
FROM node:${NODE_VERSION}
|
|
|
|
|
2023-03-17 04:09:27 +00:00
|
|
|
ARG SOURCE_TAG=''
|
2022-11-17 11:56:14 +00:00
|
|
|
ARG UID="991"
|
|
|
|
ARG GID="991"
|
|
|
|
|
|
|
|
COPY --link --from=ruby /opt/ruby /opt/ruby
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2021-03-20 20:21:57 +00:00
|
|
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
2022-11-17 11:56:14 +00:00
|
|
|
|
|
|
|
ENV DEBIAN_FRONTEND="noninteractive" \
|
|
|
|
PATH="${PATH}:/opt/ruby/bin:/opt/mastodon/bin"
|
|
|
|
|
2022-12-15 14:57:17 +00:00
|
|
|
# Ignoreing these here since we don't want to pin any versions and the Debian image removes apt-get content after use
|
|
|
|
# hadolint ignore=DL3008,DL3009
|
2021-03-20 20:21:57 +00:00
|
|
|
RUN apt-get update && \
|
2022-11-17 11:56:14 +00:00
|
|
|
echo "Etc/UTC" > /etc/localtime && \
|
|
|
|
groupadd -g "${GID}" mastodon && \
|
2022-12-15 14:57:17 +00:00
|
|
|
useradd -l -u "$UID" -g "${GID}" -m -d /opt/mastodon mastodon && \
|
2022-11-17 11:56:14 +00:00
|
|
|
apt-get -y --no-install-recommends install whois \
|
|
|
|
wget \
|
2022-11-22 04:52:18 +00:00
|
|
|
procps \
|
2022-11-17 11:56:14 +00:00
|
|
|
libssl1.1 \
|
|
|
|
libpq5 \
|
|
|
|
imagemagick \
|
|
|
|
ffmpeg \
|
|
|
|
libjemalloc2 \
|
|
|
|
libicu67 \
|
|
|
|
libidn11 \
|
|
|
|
libyaml-0-2 \
|
|
|
|
file \
|
|
|
|
ca-certificates \
|
|
|
|
tzdata \
|
|
|
|
libreadline8 \
|
|
|
|
tini && \
|
|
|
|
ln -s /opt/mastodon /mastodon
|
|
|
|
|
|
|
|
# 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 15:12:48 +00:00
|
|
|
|
2023-03-16 03:48:30 +00:00
|
|
|
COPY --link --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon
|
2019-02-24 15:32:40 +00:00
|
|
|
|
2022-11-17 11:56:14 +00:00
|
|
|
ENV RAILS_ENV="production" \
|
|
|
|
NODE_ENV="production" \
|
|
|
|
RAILS_SERVE_STATIC_FILES="true" \
|
2023-03-17 04:09:27 +00:00
|
|
|
BIND="0.0.0.0" \
|
|
|
|
SOURCE_TAG="${SOURCE_TAG}"
|
2019-02-24 15:32:40 +00:00
|
|
|
|
|
|
|
# Set the run user
|
2018-02-20 16:25:01 +00:00
|
|
|
USER mastodon
|
2022-11-17 11:56:14 +00:00
|
|
|
WORKDIR /opt/mastodon
|
2018-02-20 16:25:01 +00:00
|
|
|
|
2019-02-24 15:32:40 +00:00
|
|
|
# Set the work dir and the container entry point
|
2021-03-20 20:21:57 +00:00
|
|
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
2019-11-04 11:56:21 +00:00
|
|
|
EXPOSE 3000 4000
|