1
0

Dockerfile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # syntax=docker/dockerfile:1.4
  2. # This needs to be bullseye-slim because the Ruby image is built on bullseye-slim
  3. ARG NODE_VERSION="16.18.1-bullseye-slim"
  4. FROM ghcr.io/moritzheiber/ruby-jemalloc:3.0.6-slim as ruby
  5. FROM node:${NODE_VERSION} as build
  6. COPY --link --from=ruby /opt/ruby /opt/ruby
  7. ENV DEBIAN_FRONTEND="noninteractive" \
  8. PATH="${PATH}:/opt/ruby/bin"
  9. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  10. WORKDIR /opt/mastodon
  11. COPY Gemfile* package.json yarn.lock /opt/mastodon/
  12. # hadolint ignore=DL3008
  13. RUN apt-get update && \
  14. apt-get -yq dist-upgrade && \
  15. apt-get install -y --no-install-recommends build-essential \
  16. ca-certificates \
  17. git \
  18. libicu-dev \
  19. libidn11-dev \
  20. libpq-dev \
  21. libjemalloc-dev \
  22. zlib1g-dev \
  23. libgdbm-dev \
  24. libgmp-dev \
  25. libssl-dev \
  26. libyaml-0-2 \
  27. ca-certificates \
  28. libreadline8 \
  29. python3 \
  30. shared-mime-info && \
  31. bundle config set --local deployment 'true' && \
  32. bundle config set --local without 'development test' && \
  33. bundle config set silence_root_warning true && \
  34. bundle install -j"$(nproc)" && \
  35. yarn install --pure-lockfile --network-timeout 600000
  36. FROM node:${NODE_VERSION}
  37. ARG UID="991"
  38. ARG GID="991"
  39. COPY --link --from=ruby /opt/ruby /opt/ruby
  40. SHELL ["/bin/bash", "-o", "pipefail", "-c"]
  41. ENV DEBIAN_FRONTEND="noninteractive" \
  42. PATH="${PATH}:/opt/ruby/bin:/opt/mastodon/bin"
  43. # Ignoreing these here since we don't want to pin any versions and the Debian image removes apt-get content after use
  44. # hadolint ignore=DL3008,DL3009
  45. RUN apt-get update && \
  46. echo "Etc/UTC" > /etc/localtime && \
  47. groupadd -g "${GID}" mastodon && \
  48. useradd -l -u "$UID" -g "${GID}" -m -d /opt/mastodon mastodon && \
  49. apt-get -y --no-install-recommends install whois \
  50. wget \
  51. procps \
  52. libssl1.1 \
  53. libpq5 \
  54. imagemagick \
  55. ffmpeg \
  56. libjemalloc2 \
  57. libicu67 \
  58. libidn11 \
  59. libyaml-0-2 \
  60. file \
  61. ca-certificates \
  62. tzdata \
  63. libreadline8 \
  64. tini && \
  65. ln -s /opt/mastodon /mastodon
  66. # Note: no, cleaning here since Debian does this automatically
  67. # See the file /etc/apt/apt.conf.d/docker-clean within the Docker image's filesystem
  68. COPY --chown=mastodon:mastodon . /opt/mastodon
  69. COPY --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon
  70. ENV RAILS_ENV="production" \
  71. NODE_ENV="production" \
  72. RAILS_SERVE_STATIC_FILES="true" \
  73. BIND="0.0.0.0"
  74. # Set the run user
  75. USER mastodon
  76. WORKDIR /opt/mastodon
  77. # Precompile assets
  78. RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
  79. yarn cache clean
  80. # Set the work dir and the container entry point
  81. ENTRYPOINT ["/usr/bin/tini", "--"]
  82. EXPOSE 3000 4000