Create Dockerfile
Browse files- Dockerfile +99 -0
Dockerfile
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# syntax=docker/dockerfile:1.4
|
2 |
+
# This needs to be bullseye-slim because the Ruby image is built on bullseye-slim
|
3 |
+
ARG NODE_VERSION="16.18.1-bullseye-slim"
|
4 |
+
|
5 |
+
FROM ghcr.io/moritzheiber/ruby-jemalloc:3.0.4-slim as ruby
|
6 |
+
FROM node:${NODE_VERSION} as build
|
7 |
+
|
8 |
+
COPY --link --from=ruby /opt/ruby /opt/ruby
|
9 |
+
|
10 |
+
ENV DEBIAN_FRONTEND="noninteractive" \
|
11 |
+
PATH="${PATH}:/opt/ruby/bin"
|
12 |
+
|
13 |
+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
14 |
+
|
15 |
+
WORKDIR /opt/mastodon
|
16 |
+
COPY Gemfile* package.json yarn.lock /opt/mastodon/
|
17 |
+
|
18 |
+
# hadolint ignore=DL3008
|
19 |
+
RUN apt-get update && \
|
20 |
+
apt-get install -y --no-install-recommends build-essential \
|
21 |
+
ca-certificates \
|
22 |
+
git \
|
23 |
+
libicu-dev \
|
24 |
+
libidn11-dev \
|
25 |
+
libpq-dev \
|
26 |
+
libjemalloc-dev \
|
27 |
+
zlib1g-dev \
|
28 |
+
libgdbm-dev \
|
29 |
+
libgmp-dev \
|
30 |
+
libssl-dev \
|
31 |
+
libyaml-0-2 \
|
32 |
+
ca-certificates \
|
33 |
+
libreadline8 \
|
34 |
+
python3 \
|
35 |
+
shared-mime-info && \
|
36 |
+
bundle config set --local deployment 'true' && \
|
37 |
+
bundle config set --local without 'development test' && \
|
38 |
+
bundle config set silence_root_warning true && \
|
39 |
+
bundle install -j"$(nproc)" && \
|
40 |
+
yarn install --pure-lockfile --network-timeout 600000
|
41 |
+
|
42 |
+
FROM node:${NODE_VERSION}
|
43 |
+
|
44 |
+
ARG UID="991"
|
45 |
+
ARG GID="991"
|
46 |
+
|
47 |
+
COPY --link --from=ruby /opt/ruby /opt/ruby
|
48 |
+
|
49 |
+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
50 |
+
|
51 |
+
ENV DEBIAN_FRONTEND="noninteractive" \
|
52 |
+
PATH="${PATH}:/opt/ruby/bin:/opt/mastodon/bin"
|
53 |
+
|
54 |
+
# Ignoreing these here since we don't want to pin any versions and the Debian image removes apt-get content after use
|
55 |
+
# hadolint ignore=DL3008,DL3009
|
56 |
+
RUN apt-get update && \
|
57 |
+
echo "Etc/UTC" > /etc/localtime && \
|
58 |
+
groupadd -g "${GID}" mastodon && \
|
59 |
+
useradd -l -u "$UID" -g "${GID}" -m -d /opt/mastodon mastodon && \
|
60 |
+
apt-get -y --no-install-recommends install whois \
|
61 |
+
wget \
|
62 |
+
procps \
|
63 |
+
libssl1.1 \
|
64 |
+
libpq5 \
|
65 |
+
imagemagick \
|
66 |
+
ffmpeg \
|
67 |
+
libjemalloc2 \
|
68 |
+
libicu67 \
|
69 |
+
libidn11 \
|
70 |
+
libyaml-0-2 \
|
71 |
+
file \
|
72 |
+
ca-certificates \
|
73 |
+
tzdata \
|
74 |
+
libreadline8 \
|
75 |
+
tini && \
|
76 |
+
ln -s /opt/mastodon /mastodon
|
77 |
+
|
78 |
+
# Note: no, cleaning here since Debian does this automatically
|
79 |
+
# See the file /etc/apt/apt.conf.d/docker-clean within the Docker image's filesystem
|
80 |
+
|
81 |
+
COPY --chown=mastodon:mastodon . /opt/mastodon
|
82 |
+
COPY --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon
|
83 |
+
|
84 |
+
ENV RAILS_ENV="production" \
|
85 |
+
NODE_ENV="production" \
|
86 |
+
RAILS_SERVE_STATIC_FILES="true" \
|
87 |
+
BIND="0.0.0.0"
|
88 |
+
|
89 |
+
# Set the run user
|
90 |
+
USER mastodon
|
91 |
+
WORKDIR /opt/mastodon
|
92 |
+
|
93 |
+
# Precompile assets
|
94 |
+
RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
|
95 |
+
yarn cache clean
|
96 |
+
|
97 |
+
# Set the work dir and the container entry point
|
98 |
+
ENTRYPOINT ["/usr/bin/tini", "--"]
|
99 |
+
EXPOSE 3000 4000
|