The asonix.dog mastodon downstream
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dockerfile 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. FROM asonix/masto-deps:amd64 as build-dep
  2. # Use bash for the shell
  3. SHELL ["bash", "-c"]
  4. COPY Gemfile* package.json yarn.lock /opt/mastodon/
  5. RUN cd /opt/mastodon && \
  6. bundle install -j$(nproc) --deployment --without development test && \
  7. yarn install --pure-lockfile
  8. FROM amd64/ubuntu:18.04
  9. # Copy over all the langs needed for runtime
  10. COPY --from=build-dep /opt/node /opt/node
  11. COPY --from=build-dep /opt/ruby /opt/ruby
  12. COPY --from=build-dep /opt/jemalloc /opt/jemalloc
  13. COPY --from=build-dep /tini /tini
  14. RUN chmod +rx /tini
  15. # Add more PATHs to the PATH
  16. ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/opt/mastodon/bin"
  17. # Create the mastodon user
  18. ARG UID=991
  19. ARG GID=991
  20. RUN apt update && \
  21. echo "Etc/UTC" > /etc/localtime && \
  22. ln -s /opt/jemalloc/lib/* /usr/lib/ && \
  23. apt install -y whois wget && \
  24. addgroup --gid $GID mastodon && \
  25. useradd -m -u $UID -g $GID -d /opt/mastodon mastodon && \
  26. echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd
  27. # Install mastodon runtime deps
  28. RUN apt -y --no-install-recommends install \
  29. libssl1.1 libpq5 imagemagick ffmpeg \
  30. libicu60 libprotobuf10 libidn11 libyaml-0-2 \
  31. file ca-certificates tzdata libreadline7 && \
  32. apt -y install gcc && \
  33. ln -s /opt/mastodon /mastodon && \
  34. gem install bundler
  35. # Copy over mastodon source, and dependencies from building, and set permissions
  36. COPY --chown=mastodon:mastodon . /opt/mastodon
  37. COPY --from=build-dep --chown=mastodon:mastodon /opt/mastodon /opt/mastodon
  38. # Run mastodon services in prod mode
  39. ENV RAILS_ENV="production"
  40. ENV NODE_ENV="production"
  41. # Tell rails to serve static files
  42. ENV RAILS_SERVE_STATIC_FILES="true"
  43. ENV BIND="0.0.0.0"
  44. # Set the run user
  45. USER mastodon
  46. # Precompile assets
  47. RUN cd ~ && \
  48. OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
  49. yarn cache clean
  50. # Set the work dir and the container entry point
  51. WORKDIR /opt/mastodon
  52. ENTRYPOINT ["/tini", "--"]