Adds tcmalloc and lockless allocators to base image
[discourse_docker.git] / image / base / Dockerfile
1 # NAME: discourse/base
2 # VERSION: 1.3.9
3 FROM ubuntu:16.04
4
5 ENV PG_MAJOR 9.5
6
7 MAINTAINER Sam Saffron "https://twitter.com/samsaffron"
8
9 ADD VERSION /VERSION
10
11 RUN apt-get update && apt-get install -y lsb-release sudo curl
12 RUN echo "debconf debconf/frontend select Teletype" | debconf-set-selections
13 RUN echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main restricted universe" > /etc/apt/sources.list
14 RUN echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-updates main restricted universe" >> /etc/apt/sources.list
15 RUN echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-security main restricted universe" >> /etc/apt/sources.list
16 RUN apt-get update && apt-get -y install fping
17 RUN sh -c "fping proxy && echo 'Acquire { Retries \"0\"; HTTP { Proxy \"http://proxy:3128\";}; };' > /etc/apt/apt.conf.d/40proxy && apt-get update || true"
18 RUN apt-get -y install software-properties-common
19 RUN apt-mark hold initscripts
20 RUN apt-get -y upgrade
21 RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
22 RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" | \
23 tee /etc/apt/sources.list.d/postgres.list
24 RUN curl --silent --location https://deb.nodesource.com/setup_6.x | sudo bash -
25 RUN apt-get -y update
26 RUN apt-get -y install build-essential git wget \
27 libxslt-dev libcurl4-openssl-dev \
28 libssl-dev libyaml-dev libtool \
29 libxml2-dev gawk parallel \
30 postgresql-${PG_MAJOR} postgresql-client-${PG_MAJOR} \
31 postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev \
32 language-pack-en cron anacron \
33 psmisc rsyslog vim whois brotli libunwind-dev
34 RUN sed -i -e 's/start -q anacron/anacron -s/' /etc/cron.d/anacron
35 RUN sed -i.bak 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf
36 RUN dpkg-divert --local --rename --add /sbin/initctl
37 RUN sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl"
38 RUN apt-get -y install redis-server haproxy openssh-server
39 RUN cd / &&\
40 apt-get -y install runit monit socat &&\
41 mkdir -p /etc/runit/1.d &&\
42 apt-get clean &&\
43 rm -f /etc/apt/apt.conf.d/40proxy &&\
44 locale-gen en_US &&\
45 apt-get install -y nodejs &&\
46 npm install uglify-js -g &&\
47 npm install svgo -g
48
49 ADD install-nginx /tmp/install-nginx
50 RUN /tmp/install-nginx
51
52 RUN apt-get -y install advancecomp jhead jpegoptim libjpeg-turbo-progs optipng
53
54
55 RUN mkdir /jemalloc && cd /jemalloc &&\
56 wget https://github.com/jemalloc/jemalloc/releases/download/3.6.0/jemalloc-3.6.0.tar.bz2 &&\
57 tar -xjf jemalloc-3.6.0.tar.bz2 && cd jemalloc-3.6.0 && ./configure --prefix=/usr && make && make install &&\
58 cd / && rm -rf /jemalloc
59
60 RUN mkdir /gperftools && git clone https://github.com/gperftools/gperftools.git /gperftools &&\
61 cd /gperftools && git checkout gperftools-2.5 && ./autogen.sh && ./configure --prefix=$PWD/lib &&\
62 make install && mv lib/lib/libtcmalloc_minimal.so.4.3.0 /usr/lib && cd / && rm -rf /gperftools
63
64 RUN mkdir /lockless && cd /lockless && curl -O https://locklessinc.com/downloads/lockless_allocator_linux.tgz &&\
65 tar zxf lockless_allocator_linux.tgz && mv lockless_allocator_linux/64bit/libllalloc.so.1.4 /usr/lib &&\
66 cd / && rm -rf /lockless
67
68 RUN echo 'gem: --no-document' >> /usr/local/etc/gemrc &&\
69 mkdir /src && cd /src && git clone https://github.com/sstephenson/ruby-build.git &&\
70 cd /src/ruby-build && ./install.sh &&\
71 cd / && rm -rf /src/ruby-build && ruby-build 2.3.3 /usr/local
72
73 RUN gem install bundler &&\
74 rm -rf /usr/local/share/ri/2.3.0/system &&\
75 cd / && git clone https://github.com/SamSaffron/pups.git
76
77 ADD install-imagemagick /tmp/install-imagemagick
78 RUN /tmp/install-imagemagick
79
80 # Validate install
81 RUN ruby -e "v='`convert -version`'; ['png','tiff','jpeg','freetype'].each{ |f| ((STDERR.puts('no ' + f + ' support in imagemagick')); exit(-1)) unless v.include?(f)}"
82
83 #
84 ADD install-pngcrush /tmp/install-pngcrush
85 RUN /tmp/install-pngcrush
86
87 ADD install-gifsicle /tmp/install-gifsicle
88 RUN /tmp/install-gifsicle
89
90 ADD install-pngquant /tmp/install-pngquant
91 RUN /tmp/install-pngquant
92
93 ADD phantomjs /usr/local/bin/phantomjs
94
95 # Not using the official repo until they compile against a recent openssl
96 # RUN cd tmp && wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
97 # 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
98
99 # clean up for docker squash
100 RUN rm -fr /usr/share/man &&\
101 rm -fr /usr/share/doc &&\
102 rm -fr /usr/share/vim/vim74/tutor &&\
103 rm -fr /usr/share/vim/vim74/doc &&\
104 rm -fr /usr/share/vim/vim74/lang &&\
105 rm -fr /usr/local/share/doc &&\
106 rm -fr /usr/local/share/ruby-build &&\
107 rm -fr /root/.gem &&\
108 rm -fr /root/.npm &&\
109 rm -fr /tmp/* &&\
110 rm -fr /usr/share/vim/vim74/spell/en*
111
112
113 # this can probably be done, but I worry that people changing PG locales will have issues
114 # cd /usr/share/locale && rm -fr `ls -d */ | grep -v en`
115
116 RUN mkdir -p /etc/runit/3.d
117
118 ADD runit-1 /etc/runit/1
119 ADD runit-1.d-cleanup-pids /etc/runit/1.d/cleanup-pids
120 ADD runit-1.d-anacron /etc/runit/1.d/anacron
121 ADD runit-1.d-00-fix-var-logs /etc/runit/1.d/00-fix-var-logs
122 ADD runit-2 /etc/runit/2
123 ADD runit-3 /etc/runit/3
124 ADD boot /sbin/boot
125
126 ADD cron /etc/service/cron/run
127 ADD rsyslog /etc/service/rsyslog/run
128 ADD cron.d_anacron /etc/cron.d/anacron