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.

93 lines
2.7 KiB

  1. FROM node:8.15-alpine as node
  2. FROM ruby:2.6-alpine3.9
  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 add --no-cache -t build-dependencies \
  20. build-base \
  21. icu-dev \
  22. libidn-dev \
  23. openssl \
  24. libtool \
  25. libxml2-dev \
  26. libxslt-dev \
  27. postgresql-dev \
  28. protobuf-dev \
  29. python \
  30. && apk add --no-cache \
  31. ca-certificates \
  32. ffmpeg \
  33. file \
  34. git \
  35. icu-libs \
  36. imagemagick \
  37. libidn \
  38. libpq \
  39. libxml2 \
  40. libxslt \
  41. protobuf \
  42. tini \
  43. tzdata \
  44. && update-ca-certificates \
  45. && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
  46. && ln -s /opt/yarn/bin/yarnpkg /usr/local/bin/yarnpkg \
  47. && mkdir -p /tmp/src /opt \
  48. && wget -O libiconv.tar.gz "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
  49. && echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
  50. && tar -xzf libiconv.tar.gz -C /tmp/src \
  51. && rm libiconv.tar.gz \
  52. && cd /tmp/src/libiconv-$LIBICONV_VERSION \
  53. && ./configure --prefix=/usr/local \
  54. && make -j$(getconf _NPROCESSORS_ONLN)\
  55. && make install \
  56. && libtool --finish /usr/local/lib \
  57. && cd /mastodon \
  58. && rm -rf /tmp/*
  59. COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
  60. COPY stack-fix.c /lib
  61. RUN gcc -shared -fPIC /lib/stack-fix.c -o /lib/stack-fix.so
  62. RUN rm /lib/stack-fix.c
  63. RUN bundle config build.nokogiri --use-system-libraries --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
  64. && bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
  65. && yarn install --pure-lockfile --ignore-engines \
  66. && yarn cache clean
  67. RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon \
  68. && mkdir -p /mastodon/public/system /mastodon/public/assets /mastodon/public/packs \
  69. && chown -R mastodon:mastodon /mastodon/public
  70. COPY . /mastodon
  71. RUN chown -R mastodon:mastodon /mastodon
  72. VOLUME /mastodon/public/system
  73. USER mastodon
  74. ENV LD_PRELOAD=/lib/stack-fix.so
  75. RUN OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder bundle exec rails assets:precompile
  76. ENTRYPOINT ["/sbin/tini", "--"]