FROM ruby:3.2-alpine3.19 ARG GIT_BRANCH ARG GIT_REPOSITORY ENV RAILS_SERVE_STATIC_FILES="true" ENV RAILS_ENV="production" ENV NODE_ENV="production" COPY root/ / # Install build dependencies RUN apk add --no-cache whois nodejs yarn ca-certificates git bash \ gcc g++ make libc-dev file sed \ imagemagick protobuf-dev libpq ffmpeg icu-dev libidn-dev yaml-dev \ readline-dev postgresql-dev curl tini python3 shared-mime-info gcompat && \ update-ca-certificates # Create the mastodon user ARG UID=1001 ARG GID=1001 RUN echo "Etc/UTC" > /etc/localtime && \ mkdir -p /opt/mastodon && \ addgroup --gid $GID mastodon && \ adduser -D -u $UID -G mastodon -h /opt/mastodon mastodon && \ echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd && \ chown -R mastodon:mastodon /opt/mastodon # Install mastodon WORKDIR /opt ADD ${GIT_REPOSITORY}/archive/${GIT_BRANCH}.tar.gz /opt/mastodon.tar.gz RUN tar -zxf mastodon.tar.gz && \ chown -R ${UID}:${GID} mastodon && \ rm mastodon.tar.gz # Install dependencies WORKDIR /opt/mastodon RUN mkdir -p /opt/mastodon/.config/yarn/global && \ touch /opt/mastodon/.config/yarn/global/.yarnclean && \ gem install bundler && \ bundle config set --local deployment 'true' && \ bundle config set --local without 'development test' && \ bundle config set silence_root_warning 'true' && \ bundle install -j$(nproc) && \ yarn install --pure-lockfile --production --network-timeout=30000 # Copy compiled assets COPY --chown=${UID}:${GID} public/ /opt/mastodon/public/ ENTRYPOINT ["/sbin/tini", "--"]