]> cat aescling's git repositories - mastodon.git/blob - Dockerfile
Fix uncaught 422 and 500 errors (#11590)
[mastodon.git] / Dockerfile
1 FROM ubuntu:18.04 as build-dep
2
3 # Use bash for the shell
4 SHELL ["bash", "-c"]
5
6 # Install Node
7 ENV NODE_VER="8.15.0"
8 RUN echo "Etc/UTC" > /etc/localtime && \
9 apt update && \
10 apt -y install wget make gcc g++ python && \
11 cd ~ && \
12 wget https://nodejs.org/download/release/v$NODE_VER/node-v$NODE_VER.tar.gz && \
13 tar xf node-v$NODE_VER.tar.gz && \
14 cd node-v$NODE_VER && \
15 ./configure --prefix=/opt/node && \
16 make -j$(nproc) > /dev/null && \
17 make install
18
19 # Install jemalloc
20 ENV JE_VER="5.1.0"
21 RUN apt update && \
22 apt -y install autoconf && \
23 cd ~ && \
24 wget https://github.com/jemalloc/jemalloc/archive/$JE_VER.tar.gz && \
25 tar xf $JE_VER.tar.gz && \
26 cd jemalloc-$JE_VER && \
27 ./autogen.sh && \
28 ./configure --prefix=/opt/jemalloc && \
29 make -j$(nproc) > /dev/null && \
30 make install_bin install_include install_lib
31
32 # Install ruby
33 ENV RUBY_VER="2.6.1"
34 ENV CPPFLAGS="-I/opt/jemalloc/include"
35 ENV LDFLAGS="-L/opt/jemalloc/lib/"
36 RUN apt update && \
37 apt -y install build-essential \
38 bison libyaml-dev libgdbm-dev libreadline-dev \
39 libncurses5-dev libffi-dev zlib1g-dev libssl-dev && \
40 cd ~ && \
41 wget https://cache.ruby-lang.org/pub/ruby/${RUBY_VER%.*}/ruby-$RUBY_VER.tar.gz && \
42 tar xf ruby-$RUBY_VER.tar.gz && \
43 cd ruby-$RUBY_VER && \
44 ./configure --prefix=/opt/ruby \
45 --with-jemalloc \
46 --with-shared \
47 --disable-install-doc && \
48 ln -s /opt/jemalloc/lib/* /usr/lib/ && \
49 make -j$(nproc) > /dev/null && \
50 make install
51
52 ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin"
53
54 RUN npm install -g yarn && \
55 gem install bundler && \
56 apt update && \
57 apt -y install git libicu-dev libidn11-dev \
58 libpq-dev libprotobuf-dev protobuf-compiler
59
60 COPY Gemfile* package.json yarn.lock /opt/mastodon/
61
62 RUN cd /opt/mastodon && \
63 bundle install -j$(nproc) --deployment --without development test && \
64 yarn install --pure-lockfile
65
66 FROM ubuntu:18.04
67
68 # Copy over all the langs needed for runtime
69 COPY --from=build-dep /opt/node /opt/node
70 COPY --from=build-dep /opt/ruby /opt/ruby
71 COPY --from=build-dep /opt/jemalloc /opt/jemalloc
72
73 # Add more PATHs to the PATH
74 ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/opt/mastodon/bin"
75
76 # Create the mastodon user
77 ARG UID=991
78 ARG GID=991
79 RUN apt update && \
80 echo "Etc/UTC" > /etc/localtime && \
81 ln -s /opt/jemalloc/lib/* /usr/lib/ && \
82 apt install -y whois wget && \
83 addgroup --gid $GID mastodon && \
84 useradd -m -u $UID -g $GID -d /opt/mastodon mastodon && \
85 echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd
86
87 # Install mastodon runtime deps
88 RUN apt -y --no-install-recommends install \
89 libssl1.1 libpq5 imagemagick ffmpeg \
90 libicu60 libprotobuf10 libidn11 libyaml-0-2 \
91 file ca-certificates tzdata libreadline7 && \
92 apt -y install gcc && \
93 ln -s /opt/mastodon /mastodon && \
94 gem install bundler && \
95 rm -rf /var/cache && \
96 rm -rf /var/lib/apt/lists/*
97
98 # Add tini
99 ENV TINI_VERSION="0.18.0"
100 ENV TINI_SUM="12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855"
101 ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini /tini
102 RUN echo "$TINI_SUM tini" | sha256sum -c -
103 RUN chmod +x /tini
104
105 # Copy over mastodon source, and dependencies from building, and set permissions
106 COPY --chown=mastodon:mastodon . /opt/mastodon
107 COPY --from=build-dep --chown=mastodon:mastodon /opt/mastodon /opt/mastodon
108
109 # Run mastodon services in prod mode
110 ENV RAILS_ENV="production"
111 ENV NODE_ENV="production"
112
113 # Tell rails to serve static files
114 ENV RAILS_SERVE_STATIC_FILES="true"
115 ENV BIND="0.0.0.0"
116
117 # Set the run user
118 USER mastodon
119
120 # Precompile assets
121 RUN cd ~ && \
122 OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
123 yarn cache clean
124
125 # Set the work dir and the container entry point
126 WORKDIR /opt/mastodon
127 ENTRYPOINT ["/tini", "--"]
This page took 0.084828 seconds and 4 git commands to generate.