Revert f4973e9280e2604a426767e9eca4f698e0cad5b3 since we can't use Rails at this...
[discourse_docker.git] / image / base / Dockerfile
index bba96636d12792d0376f0760d62c8f96d8f414bc..29c570fd1bf74ed1a3d33493f0312de87aa5a7ab 100644 (file)
@@ -1,14 +1,14 @@
 # NAME:     discourse/base
-# VERSION:  1.4.0
+# VERSION:  release
 FROM ubuntu:16.04
 
-ENV PG_MAJOR 9.5
+ENV PG_MAJOR 10
 ENV RUBY_ALLOCATOR /usr/lib/libjemalloc.so.1
 ENV COMPRESS_BROTLI 1
 
-MAINTAINER Sam Saffron "https://twitter.com/samsaffron"
+#LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\""
 
-ADD VERSION /VERSION
+RUN echo 2.0.`date +%Y%m%d` > /VERSION
 
 RUN apt-get update && apt-get install -y lsb-release sudo curl
 RUN echo "debconf debconf/frontend select Teletype" | debconf-set-selections
@@ -23,7 +23,7 @@ RUN apt-get -y upgrade
 RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
 RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" | \
         tee /etc/apt/sources.list.d/postgres.list
-RUN curl --silent --location https://deb.nodesource.com/setup_6.x | sudo bash -
+RUN curl --silent --location https://deb.nodesource.com/setup_8.x | sudo bash -
 RUN apt-get -y update
 RUN apt-get -y install build-essential git wget \
                        libxslt-dev libcurl4-openssl-dev \
@@ -32,7 +32,8 @@ RUN apt-get -y install build-essential git wget \
                        postgresql-${PG_MAJOR} postgresql-client-${PG_MAJOR} \
                        postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev \
                        language-pack-en cron anacron \
-                       psmisc rsyslog vim whois brotli libunwind-dev
+                       psmisc rsyslog vim whois brotli libunwind-dev \
+                       libtcmalloc-minimal4
 RUN sed -i -e 's/start -q anacron/anacron -s/' /etc/cron.d/anacron
 RUN sed -i.bak 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf
 RUN dpkg-divert --local --rename --add /sbin/initctl
@@ -45,36 +46,34 @@ RUN cd / &&\
     rm -f /etc/apt/apt.conf.d/40proxy &&\
     locale-gen en_US &&\
     apt-get install -y nodejs &&\
-    npm install uglify-js -g &&\
-    npm install svgo -g
+    npm install -g uglify-js@"<3" &&\
+    npm install -g svgo
 
 ADD install-nginx /tmp/install-nginx
 RUN /tmp/install-nginx
 
 RUN apt-get -y install advancecomp jhead jpegoptim libjpeg-turbo-progs optipng
 
-
-RUN mkdir /jemalloc && cd /jemalloc &&\
+RUN mkdir /jemalloc-stable && cd /jemalloc-stable &&\
       wget https://github.com/jemalloc/jemalloc/releases/download/3.6.0/jemalloc-3.6.0.tar.bz2 &&\
       tar -xjf jemalloc-3.6.0.tar.bz2 && cd jemalloc-3.6.0 && ./configure --prefix=/usr && make && make install &&\
-      cd / && rm -rf /jemalloc
-
-RUN mkdir /gperftools && git clone https://github.com/gperftools/gperftools.git /gperftools &&\
-      cd /gperftools && git checkout gperftools-2.5 && ./autogen.sh && ./configure --prefix=$PWD/lib &&\
-      make install && mv lib/lib/libtcmalloc_minimal.so.4.3.0 /usr/lib && cd / && rm -rf /gperftools
+      cd / && rm -rf /jemalloc-stable
 
-RUN mkdir /lockless && cd /lockless && curl -O https://locklessinc.com/downloads/lockless_allocator_linux.tgz &&\
-      tar zxf lockless_allocator_linux.tgz && mv lockless_allocator_linux/64bit/libllalloc.so.1.4 /usr/lib &&\
-      cd / && rm -rf /lockless
+RUN mkdir /jemalloc-new && cd /jemalloc-new &&\
+      wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2 &&\
+      tar -xjf jemalloc-5.1.0.tar.bz2 && cd jemalloc-5.1.0 && ./configure --prefix=/usr --with-install-suffix=5.1.0 && make build_lib && make install_lib &&\
+      cd / && rm -rf /jemalloc-new
 
 RUN echo 'gem: --no-document' >> /usr/local/etc/gemrc &&\
     mkdir /src && cd /src && git clone https://github.com/sstephenson/ruby-build.git &&\
     cd /src/ruby-build && ./install.sh &&\
-    cd / && rm -rf /src/ruby-build && ruby-build 2.4.1 /usr/local
+    cd / && rm -rf /src/ruby-build && (ruby-build 2.5.1 /usr/local)
+
+RUN gem update --system
 
-RUN gem install bundler &&\
-    rm -rf /usr/local/share/ri/2.4.1/system &&\
-    cd / && git clone https://github.com/SamSaffron/pups.git
+RUN gem install bundler --force &&\
+    rm -rf /usr/local/share/ri/2.5.1/system &&\
+    cd / && git clone https://github.com/discourse/pups.git
 
 ADD install-imagemagick /tmp/install-imagemagick
 RUN /tmp/install-imagemagick
@@ -91,11 +90,11 @@ RUN /tmp/install-gifsicle
 ADD install-pngquant /tmp/install-pngquant
 RUN /tmp/install-pngquant
 
-ADD phantomjs /usr/local/bin/phantomjs
-
-# Not using the official repo until they compile against a recent openssl
-# RUN cd tmp && wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
-# RUN cd tmp && tar jxf phantomjs-2.1.1-linux-x86_64.tar.bz2 && mv /tmp/phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/local/bin
+# This tool allows us to disable huge page support for our current process
+# since the flag is preserved through forks and execs it can be used on any
+# process
+ADD thpoff.c /src/thpoff.c
+RUN gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c
 
 # clean up for docker squash
 RUN   rm -fr /usr/share/man &&\
@@ -127,3 +126,16 @@ ADD boot /sbin/boot
 ADD cron /etc/service/cron/run
 ADD rsyslog /etc/service/rsyslog/run
 ADD cron.d_anacron /etc/cron.d/anacron
+
+
+# Discourse specific bits
+RUN useradd discourse -s /bin/bash -m -U &&\
+    mkdir -p /var/www &&\
+    cd /var/www &&\
+    git clone https://github.com/discourse/discourse.git &&\
+    cd discourse &&\
+    git remote set-branches --add origin tests-passed &&\
+    chown -R discourse:discourse /var/www/discourse &&\
+    cd /var/www/discourse &&\
+    sudo -u discourse bundle install --deployment --without test --without development &&\
+    find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +