Jesus is not king, and Trump did not win the election. | Old leaked git history merged with "official" release history
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.

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