Dockerfile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. FROM ruby:2.4.4-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. RUN bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
  59. && bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without test development \
  60. && yarn --pure-lockfile \
  61. && yarn cache clean
  62. RUN addgroup -g ${GID} mastodon && adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon \
  63. && mkdir -p /mastodon/public/system /mastodon/public/assets /mastodon/public/packs \
  64. && chown -R mastodon:mastodon /mastodon/public
  65. COPY . /mastodon
  66. RUN chown -R mastodon:mastodon /mastodon
  67. VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs
  68. USER mastodon
  69. ENTRYPOINT ["/sbin/tini", "--"]