Dockerfile 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. FROM node:8.14.0-alpine as node
  2. FROM ruby:2.4.5-alpine3.8
  3. LABEL maintainer="https://github.com/tootsuite/mastodon" \
  4. description="Your self-hosted, globally interconnected microblogging community"
  5. ARG UID=991
  6. ARG GID=991
  7. ENV PATH=/mastodon/bin:$PATH \
  8. RAILS_SERVE_STATIC_FILES=true \
  9. RAILS_ENV=production \
  10. NODE_ENV=production
  11. ARG LIBICONV_VERSION=1.15
  12. ARG LIBICONV_DOWNLOAD_SHA256=ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178
  13. EXPOSE 3000 4000
  14. WORKDIR /mastodon
  15. COPY --from=node /usr/local/bin/node /usr/local/bin/node
  16. COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
  17. COPY --from=node /usr/local/bin/npm /usr/local/bin/npm
  18. COPY --from=node /opt/yarn-* /opt/yarn
  19. RUN apk -U upgrade \
  20. && apk add -t build-dependencies \
  21. build-base \
  22. icu-dev \
  23. libidn-dev \
  24. libressl \
  25. libtool \
  26. libxml2-dev \
  27. libxslt-dev \
  28. postgresql-dev \
  29. protobuf-dev \
  30. python \
  31. && apk add \
  32. ca-certificates \
  33. ffmpeg \
  34. file \
  35. git \
  36. icu-libs \
  37. imagemagick \
  38. libidn \
  39. libpq \
  40. libxml2 \
  41. libxslt \
  42. protobuf \
  43. tini \
  44. tzdata \
  45. && update-ca-certificates \
  46. && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
  47. && ln -s /opt/yarn/bin/yarnpkg /usr/local/bin/yarnpkg \
  48. && mkdir -p /tmp/src /opt \
  49. && wget -O libiconv.tar.gz "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
  50. && echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
  51. && tar -xzf libiconv.tar.gz -C /tmp/src \
  52. && rm libiconv.tar.gz \
  53. && cd /tmp/src/libiconv-$LIBICONV_VERSION \
  54. && ./configure --prefix=/usr/local \
  55. && make -j$(getconf _NPROCESSORS_ONLN)\
  56. && make install \
  57. && libtool --finish /usr/local/lib \
  58. && cd /mastodon \
  59. && rm -rf /tmp/* /var/cache/apk/*
  60. COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
  61. RUN bundle config build.nokogiri --use-system-libraries --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
  62. && bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
  63. && yarn install --pure-lockfile --ignore-engines \
  64. && yarn cache clean
  65. RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon \
  66. && mkdir -p /mastodon/public/system /mastodon/public/assets /mastodon/public/packs \
  67. && chown -R mastodon:mastodon /mastodon/public
  68. COPY . /mastodon
  69. RUN chown -R mastodon:mastodon /mastodon
  70. VOLUME /mastodon/public/system
  71. USER mastodon
  72. RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile
  73. ENTRYPOINT ["/sbin/tini", "--"]