# Install jemalloc
ENV JE_VER="5.1.0"
-RUN apt -y install autoconf && \
+RUN apt update && \
+ apt -y install autoconf && \
cd ~ && \
wget https://github.com/jemalloc/jemalloc/archive/$JE_VER.tar.gz && \
tar xf $JE_VER.tar.gz && \
ENV RUBY_VER="2.6.1"
ENV CPPFLAGS="-I/opt/jemalloc/include"
ENV LDFLAGS="-L/opt/jemalloc/lib/"
-RUN apt -y install build-essential \
+RUN apt update && \
+ apt -y install build-essential \
bison libyaml-dev libgdbm-dev libreadline-dev \
libncurses5-dev libffi-dev zlib1g-dev libssl-dev && \
cd ~ && \
ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin"
RUN npm install -g yarn && \
- gem install bundler
+ gem install bundler && \
+ apt update && \
+ apt -y install git libicu-dev libidn11-dev \
+ libpq-dev libprotobuf-dev protobuf-compiler
-COPY . /opt/mastodon
+COPY Gemfile* package.json yarn.lock /opt/mastodon/
-RUN apt -y install git libicu-dev libidn11-dev \
- libpq-dev libprotobuf-dev protobuf-compiler && \
- cd /opt/mastodon && \
+RUN cd /opt/mastodon && \
bundle install -j$(nproc) --deployment --without development test && \
yarn install --pure-lockfile
useradd -m -u $UID -g $GID -d /opt/mastodon mastodon && \
echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd
-# Copy over masto source from building and set permissions
-COPY --from=build-dep --chown=mastodon:mastodon /opt/mastodon /opt/mastodon
-
# Install masto runtime deps
RUN apt -y --no-install-recommends install \
libssl1.1 libpq5 imagemagick ffmpeg \
file ca-certificates tzdata libreadline7 && \
apt -y install gcc && \
ln -s /opt/mastodon /mastodon && \
- gem install bundler
-
-# Clean up more dirs
-RUN rm -rf /var/cache && \
- rm -rf /var/apt
+ gem install bundler && \
+ rm -rf /var/cache && \
+ rm -rf /var/lib/apt
# Add tini
ENV TINI_VERSION="0.18.0"
RUN echo "$TINI_SUM tini" | sha256sum -c -
RUN chmod +x /tini
+# Copy over masto source, and dependencies from building, and set permissions
+COPY --chown=mastodon:mastodon . /opt/mastodon
+COPY --from=build-dep --chown=mastodon:mastodon /opt/mastodon /opt/mastodon
+
# Run masto services in prod mode
ENV RAILS_ENV="production"
ENV NODE_ENV="production"