The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

127 lines
3.7 KiB

  1. FROM ubuntu:18.04 as build-dep
  2. # Use bash for the shell
  3. SHELL ["bash", "-c"]
  4. # Install Node
  5. ENV NODE_VER="8.15.0"
  6. RUN echo "Etc/UTC" > /etc/localtime && \
  7. apt update && \
  8. apt -y install wget make gcc g++ python && \
  9. cd ~ && \
  10. wget https://nodejs.org/download/release/v$NODE_VER/node-v$NODE_VER.tar.gz && \
  11. tar xf node-v$NODE_VER.tar.gz && \
  12. cd node-v$NODE_VER && \
  13. ./configure --prefix=/opt/node && \
  14. make -j$(nproc) > /dev/null && \
  15. make install
  16. # Install jemalloc
  17. ENV JE_VER="5.1.0"
  18. RUN apt update && \
  19. apt -y install autoconf && \
  20. cd ~ && \
  21. wget https://github.com/jemalloc/jemalloc/archive/$JE_VER.tar.gz && \
  22. tar xf $JE_VER.tar.gz && \
  23. cd jemalloc-$JE_VER && \
  24. ./autogen.sh && \
  25. ./configure --prefix=/opt/jemalloc && \
  26. make -j$(nproc) > /dev/null && \
  27. make install_bin install_include install_lib
  28. # Install ruby
  29. ENV RUBY_VER="2.6.1"
  30. ENV CPPFLAGS="-I/opt/jemalloc/include"
  31. ENV LDFLAGS="-L/opt/jemalloc/lib/"
  32. RUN apt update && \
  33. apt -y install build-essential \
  34. bison libyaml-dev libgdbm-dev libreadline-dev \
  35. libncurses5-dev libffi-dev zlib1g-dev libssl-dev && \
  36. cd ~ && \
  37. wget https://cache.ruby-lang.org/pub/ruby/${RUBY_VER%.*}/ruby-$RUBY_VER.tar.gz && \
  38. tar xf ruby-$RUBY_VER.tar.gz && \
  39. cd ruby-$RUBY_VER && \
  40. ./configure --prefix=/opt/ruby \
  41. --with-jemalloc \
  42. --with-shared \
  43. --disable-install-doc && \
  44. ln -s /opt/jemalloc/lib/* /usr/lib/ && \
  45. make -j$(nproc) > /dev/null && \
  46. make install
  47. ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin"
  48. RUN npm install -g yarn && \
  49. gem install bundler && \
  50. apt update && \
  51. apt -y install git libicu-dev libidn11-dev \
  52. libpq-dev libprotobuf-dev protobuf-compiler
  53. COPY Gemfile* package.json yarn.lock /opt/mastodon/
  54. RUN cd /opt/mastodon && \
  55. bundle install -j$(nproc) --deployment --without development test && \
  56. yarn install --pure-lockfile
  57. FROM ubuntu:18.04
  58. # Copy over all the langs needed for runtime
  59. COPY --from=build-dep /opt/node /opt/node
  60. COPY --from=build-dep /opt/ruby /opt/ruby
  61. COPY --from=build-dep /opt/jemalloc /opt/jemalloc
  62. # Add more PATHs to the PATH
  63. ENV PATH="${PATH}:/opt/ruby/bin:/opt/node/bin:/opt/mastodon/bin"
  64. # Create the mastodon user
  65. ARG UID=991
  66. ARG GID=991
  67. RUN apt update && \
  68. echo "Etc/UTC" > /etc/localtime && \
  69. ln -s /opt/jemalloc/lib/* /usr/lib/ && \
  70. apt install -y whois wget && \
  71. addgroup --gid $GID mastodon && \
  72. useradd -m -u $UID -g $GID -d /opt/mastodon mastodon && \
  73. echo "mastodon:`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 24 | mkpasswd -s -m sha-256`" | chpasswd
  74. # Install mastodon runtime deps
  75. RUN apt -y --no-install-recommends install \
  76. libssl1.1 libpq5 imagemagick ffmpeg \
  77. libicu60 libprotobuf10 libidn11 libyaml-0-2 \
  78. file ca-certificates tzdata libreadline7 && \
  79. apt -y install gcc && \
  80. ln -s /opt/mastodon /mastodon && \
  81. gem install bundler && \
  82. rm -rf /var/cache && \
  83. rm -rf /var/lib/apt/lists/*
  84. # Add tini
  85. ENV TINI_VERSION="0.18.0"
  86. ENV TINI_SUM="12d20136605531b09a2c2dac02ccee85e1b874eb322ef6baf7561cd93f93c855"
  87. ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini /tini
  88. RUN echo "$TINI_SUM tini" | sha256sum -c -
  89. RUN chmod +x /tini
  90. # Copy over mastodon source, and dependencies from building, and set permissions
  91. COPY --chown=mastodon:mastodon . /opt/mastodon
  92. COPY --from=build-dep --chown=mastodon:mastodon /opt/mastodon /opt/mastodon
  93. # Run mastodon services in prod mode
  94. ENV RAILS_ENV="production"
  95. ENV NODE_ENV="production"
  96. # Tell rails to serve static files
  97. ENV RAILS_SERVE_STATIC_FILES="true"
  98. # Set the run user
  99. USER mastodon
  100. # Precompile assets
  101. RUN cd ~ && \
  102. OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
  103. yarn cache clean
  104. # Set the work dir and the container entry point
  105. WORKDIR /opt/mastodon
  106. ENTRYPOINT ["/tini", "--"]