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