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.

88 lines
2.6 KiB

  1. FROM ruby:2.4.3-alpine3.6
  2. LABEL maintainer="https://github.com/tootsuite/mastodon" \
  3. description="Your self-hosted, globally interconnected microblogging community"
  4. ARG UID=991
  5. ARG GID=991
  6. ENV RAILS_SERVE_STATIC_FILES=true \
  7. RAILS_ENV=production NODE_ENV=production
  8. ARG YARN_VERSION=1.3.2
  9. ARG YARN_DOWNLOAD_SHA256=6cfe82e530ef0837212f13e45c1565ba53f5199eec2527b85ecbcd88bf26821d
  10. ARG LIBICONV_VERSION=1.15
  11. ARG LIBICONV_DOWNLOAD_SHA256=ccf536620a45458d26ba83887a983b96827001e92a13847b45e4925cc8913178
  12. EXPOSE 3000 4000
  13. WORKDIR /mastodon
  14. RUN apk -U upgrade \
  15. && apk add -t build-dependencies \
  16. build-base \
  17. icu-dev \
  18. libidn-dev \
  19. libressl \
  20. libtool \
  21. postgresql-dev \
  22. protobuf-dev \
  23. python \
  24. && apk add \
  25. ca-certificates \
  26. ffmpeg \
  27. file \
  28. git \
  29. icu-libs \
  30. imagemagick \
  31. libidn \
  32. libpq \
  33. nodejs \
  34. nodejs-npm \
  35. protobuf \
  36. tini \
  37. tzdata \
  38. && update-ca-certificates \
  39. && mkdir -p /tmp/src /opt \
  40. && wget -O yarn.tar.gz "https://github.com/yarnpkg/yarn/releases/download/v$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz" \
  41. && echo "$YARN_DOWNLOAD_SHA256 *yarn.tar.gz" | sha256sum -c - \
  42. && tar -xzf yarn.tar.gz -C /tmp/src \
  43. && rm yarn.tar.gz \
  44. && mv /tmp/src/yarn-v$YARN_VERSION /opt/yarn \
  45. && ln -s /opt/yarn/bin/yarn /usr/local/bin/yarn \
  46. && wget -O libiconv.tar.gz "https://ftp.gnu.org/pub/gnu/libiconv/libiconv-$LIBICONV_VERSION.tar.gz" \
  47. && echo "$LIBICONV_DOWNLOAD_SHA256 *libiconv.tar.gz" | sha256sum -c - \
  48. && tar -xzf libiconv.tar.gz -C /tmp/src \
  49. && rm libiconv.tar.gz \
  50. && cd /tmp/src/libiconv-$LIBICONV_VERSION \
  51. && ./configure --prefix=/usr/local \
  52. && make -j$(getconf _NPROCESSORS_ONLN)\
  53. && make install \
  54. && libtool --finish /usr/local/lib \
  55. && cd /mastodon \
  56. && rm -rf /tmp/* /var/cache/apk/*
  57. COPY Gemfile Gemfile.lock package.json yarn.lock .yarnclean /mastodon/
  58. COPY stack-fix.c /lib
  59. RUN gcc -shared -fPIC /lib/stack-fix.c -o /lib/stack-fix.so
  60. RUN rm /lib/stack-fix.c
  61. RUN bundle config build.nokogiri --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 --pure-lockfile \
  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 /mastodon/public/assets /mastodon/public/packs
  71. USER mastodon
  72. ENV LD_PRELOAD=/lib/stack-fix.so
  73. ENTRYPOINT ["/sbin/tini", "--"]