]> cat aescling's git repositories - mastodon.git/blob - Dockerfile
Bump ox from 2.14.3 to 2.14.4 (#15941)
[mastodon.git] / Dockerfile
1 FROM ubuntu:20.04 as build-dep
2
3 # Use bash for the shell
4 SHELL ["/bin/bash", "-c"]
5
6 # Install Node v12 (LTS)
7 ENV NODE_VER="12.21.0"
8 RUN ARCH= && \
9 dpkgArch="$(dpkg --print-architecture)" && \
10 case "${dpkgArch##*-}" in \
11 amd64) ARCH='x64';; \
12 ppc64el) ARCH='ppc64le';; \
13 s390x) ARCH='s390x';; \
14 arm64) ARCH='arm64';; \
15 armhf) ARCH='armv7l';; \
16 i386) ARCH='x86';; \
17 *) echo "unsupported architecture"; exit 1 ;; \
18 esac && \
19 echo "Etc/UTC" > /etc/localtime && \
20 apt-get update && \
21 apt-get install -y --no-install-recommends ca-certificates wget python && \
22 cd ~ && \
23 wget -q https://nodejs.org/download/release/v$NODE_VER/node-v$NODE_VER-linux-$ARCH.tar.gz && \
24 tar xf node-v$NODE_VER-linux-$ARCH.tar.gz && \
25 rm node-v$NODE_VER-linux-$ARCH.tar.gz && \
26 mv node-v$NODE_VER-linux-$ARCH /opt/node
27
28 # Install Ruby
29 ENV RUBY_VER="2.7.2"
30 RUN apt-get update && \
31 apt-get install -y --no-install-recommends build-essential \
32 bison libyaml-dev libgdbm-dev libreadline-dev libjemalloc-dev \
33 libncurses5-dev libffi-dev zlib1g-dev libssl-dev && \
34 cd ~ && \
35 wget https://cache.ruby-lang.org/pub/ruby/${RUBY_VER%.*}/ruby-$RUBY_VER.tar.gz && \
36 tar xf ruby-$RUBY_VER.tar.gz && \
37 cd ruby-$RUBY_VER && \
38 ./configure --prefix=/opt/ruby \
39 --with-jemalloc \
40 --with-shared \
41 --disable-install-doc && \
42 make -j"$(nproc)" > /dev/null && \
43 make install && \
44 rm -rf ../ruby-$RUBY_VER.tar.gz ../ruby-$RUBY_VER
45
46 ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin"
47
48 RUN npm install -g yarn && \
49 gem install bundler && \
50 apt-get update && \
51 apt-get install -y --no-install-recommends git libicu-dev libidn11-dev \
52 libpq-dev libprotobuf-dev protobuf-compiler
53
54 COPY Gemfile* package.json yarn.lock /opt/mastodon/
55
56 RUN cd /opt/mastodon && \
57 bundle config set deployment 'true' && \
58 bundle config set without 'development test' && \
59 bundle install -j"$(nproc)" && \
60 yarn install --pure-lockfile
61
62 FROM ubuntu:20.04
63
64 # Copy over all the langs needed for runtime
65 COPY --from=build-dep /opt/node /opt/node
66 COPY --from=build-dep /opt/ruby /opt/ruby
67
68 # Add more PATHs to the PATH
69 ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/opt/mastodon/bin"
70
71 # Create the mastodon user
72 ARG UID=991
73 ARG GID=991
74 SHELL ["/bin/bash", "-o", "pipefail", "-c"]
75 RUN apt-get update && \
76 echo "Etc/UTC" > /etc/localtime && \
77 apt-get install -y --no-install-recommends whois wget && \
78 addgroup --gid $GID mastodon && \
79 useradd -m -u $UID -g $GID -d /opt/mastodon mastodon && \
80 echo "mastodon:$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256)" | chpasswd && \
81 rm -rf /var/lib/apt/lists/*
82
83 # Install mastodon runtime deps
84 RUN apt-get update && \
85 apt-get -y --no-install-recommends install \
86 libssl1.1 libpq5 imagemagick ffmpeg libjemalloc2 \
87 libicu66 libprotobuf17 libidn11 libyaml-0-2 \
88 file ca-certificates tzdata libreadline8 gcc tini && \
89 ln -s /opt/mastodon /mastodon && \
90 gem install bundler && \
91 rm -rf /var/cache && \
92 rm -rf /var/lib/apt/lists/*
93
94 # Copy over mastodon source, and dependencies from building, and set permissions
95 COPY --chown=mastodon:mastodon . /opt/mastodon
96 COPY --from=build-dep --chown=mastodon:mastodon /opt/mastodon /opt/mastodon
97
98 # Run mastodon services in prod mode
99 ENV RAILS_ENV="production"
100 ENV NODE_ENV="production"
101
102 # Tell rails to serve static files
103 ENV RAILS_SERVE_STATIC_FILES="true"
104 ENV BIND="0.0.0.0"
105
106 # Set the run user
107 USER mastodon
108
109 # Precompile assets
110 RUN cd ~ && \
111 OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
112 yarn cache clean
113
114 # Set the work dir and the container entry point
115 WORKDIR /opt/mastodon
116 ENTRYPOINT ["/usr/bin/tini", "--"]
117 EXPOSE 3000 4000
This page took 0.082831 seconds and 5 git commands to generate.