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.

99 lines
2.8 KiB

  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.19-bullseye-slim"
  4. FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.1-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 install -y --no-install-recommends build-essential \
  15. ca-certificates \
  16. git \
  17. libicu-dev \
  18. libidn11-dev \
  19. libpq-dev \
  20. libjemalloc-dev \
  21. zlib1g-dev \
  22. libgdbm-dev \
  23. libgmp-dev \
  24. libssl-dev \
  25. libyaml-0-2 \
  26. ca-certificates \
  27. libreadline8 \
  28. python3 \
  29. shared-mime-info && \
  30. bundle config set --local deployment 'true' && \
  31. bundle config set --local without 'development test' && \
  32. bundle config set silence_root_warning true && \
  33. bundle install -j"$(nproc)" && \
  34. yarn install --pure-lockfile --production --network-timeout 600000 && \
  35. yarn cache clean
  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. # Set the work dir and the container entry point
  80. ENTRYPOINT ["/usr/bin/tini", "--"]
  81. EXPOSE 3000 4000