Dockerfile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. postgresql-dev \
  27. protobuf-dev \
  28. python \
  29. && apk add \
  30. ca-certificates \
  31. ffmpeg \
  32. file \
  33. git \
  34. icu-libs \
  35. imagemagick \
  36. libidn \
  37. libpq \
  38. protobuf \
  39. tini \
  40. tzdata \
  41. && update-ca-certificates \
  42. && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
  43. && ln -s /opt/yarn/bin/yarnpkg /usr/local/bin/yarnpkg \
  44. && mkdir -p /tmp/src /opt \
  45. && wget -O libiconv.tar.gz "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
  46. && echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
  47. && tar -xzf libiconv.tar.gz -C /tmp/src \
  48. && rm libiconv.tar.gz \
  49. && cd /tmp/src/libiconv-$LIBICONV_VERSION \
  50. && ./configure --prefix=/usr/local \
  51. && make -j$(getconf _NPROCESSORS_ONLN)\
  52. && make install \
  53. && libtool --finish /usr/local/lib \
  54. && cd /mastodon \
  55. && rm -rf /tmp/* /var/cache/apk/*
  56. COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
  57. RUN bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
  58. && bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
  59. && yarn install --pure-lockfile --ignore-engines \
  60. && yarn cache clean
  61. RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon \
  62. && mkdir -p /mastodon/public/system /mastodon/public/assets /mastodon/public/packs \
  63. && chown -R mastodon:mastodon /mastodon/public
  64. COPY . /mastodon
  65. RUN chown -R mastodon:mastodon /mastodon
  66. VOLUME /mastodon/public/system
  67. USER mastodon
  68. RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile
  69. ENTRYPOINT ["/sbin/tini", "--"]