Include official plugins and install their gems in discourse_test (#431)
[discourse_docker.git] / image / base / Dockerfile
CommitLineData
e8b9677b 1# NAME: discourse/base
d288199f 2# VERSION: release
00dab51a 3FROM ubuntu:16.04
e1903539 4
b0f00a0c 5ENV PG_MAJOR 10
af28cd0c 6ENV RUBY_ALLOCATOR /usr/lib/libjemalloc.so.1
c2c7a3d8 7ENV RAILS_ENV production
8e8c1172 8
a00700c1 9#LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\""
e1903539 10
ac9d4dfd 11RUN echo 2.0.`date +%Y%m%d` > /VERSION
0b72000a 12
00dab51a
GXT
13RUN apt-get update && apt-get install -y lsb-release sudo curl
14RUN echo "debconf debconf/frontend select Teletype" | debconf-set-selections
15RUN echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main restricted universe" > /etc/apt/sources.list
16RUN echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-updates main restricted universe" >> /etc/apt/sources.list
17RUN echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc)-security main restricted universe" >> /etc/apt/sources.list
18RUN apt-get update && apt-get -y install fping
19RUN sh -c "fping proxy && echo 'Acquire { Retries \"0\"; HTTP { Proxy \"http://proxy:3128\";}; };' > /etc/apt/apt.conf.d/40proxy && apt-get update || true"
20RUN apt-get -y install software-properties-common
21RUN apt-mark hold initscripts
22RUN apt-get -y upgrade
00dab51a
GXT
23RUN curl http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -
24RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main" | \
25 tee /etc/apt/sources.list.d/postgres.list
ff9ddabe 26RUN curl --silent --location https://deb.nodesource.com/setup_10.x | sudo bash -
00dab51a
GXT
27RUN apt-get -y update
28RUN apt-get -y install build-essential git wget \
d08dd53f
RH
29 libxslt-dev libcurl4-openssl-dev \
30 libssl-dev libyaml-dev libtool \
d821539c 31 libxml2-dev gawk parallel \
8785ccc5
RSS
32 postgresql-${PG_MAJOR} postgresql-client-${PG_MAJOR} \
33 postgresql-contrib-${PG_MAJOR} libpq-dev libreadline-dev \
e8b9677b 34 language-pack-en cron anacron \
1d55926a 35 psmisc rsyslog vim whois brotli libunwind-dev \
d0323565 36 libtcmalloc-minimal4
00dab51a
GXT
37RUN sed -i -e 's/start -q anacron/anacron -s/' /etc/cron.d/anacron
38RUN sed -i.bak 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf
39RUN dpkg-divert --local --rename --add /sbin/initctl
40RUN sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl"
d5c4bf28 41RUN apt-get -y install haproxy openssh-server
00dab51a 42RUN cd / &&\
2cc4e49f 43 apt-get -y install runit monit socat &&\
23022c1d 44 mkdir -p /etc/runit/1.d &&\
d08dd53f 45 apt-get clean &&\
2bdce9f4 46 rm -f /etc/apt/apt.conf.d/40proxy &&\
be82e068 47 locale-gen en_US &&\
edcdd0c9 48 apt-get install -y nodejs &&\
44fbae48 49 npm install -g uglify-js@"<3" &&\
9a4dca18 50 npm install -g svgo
e8b9677b
S
51
52ADD install-nginx /tmp/install-nginx
53RUN /tmp/install-nginx
54
536ca9dd
S
55RUN apt-get -y install advancecomp jhead jpegoptim libjpeg-turbo-progs optipng
56
19f0b0b9 57RUN mkdir /jemalloc-stable && cd /jemalloc-stable &&\
5c7552e1
RSS
58 wget https://github.com/jemalloc/jemalloc/releases/download/3.6.0/jemalloc-3.6.0.tar.bz2 &&\
59 tar -xjf jemalloc-3.6.0.tar.bz2 && cd jemalloc-3.6.0 && ./configure --prefix=/usr && make && make install &&\
19f0b0b9
RSS
60 cd / && rm -rf /jemalloc-stable
61
62RUN mkdir /jemalloc-new && cd /jemalloc-new &&\
bf323d99
RSS
63 wget https://github.com/jemalloc/jemalloc/releases/download/5.1.0/jemalloc-5.1.0.tar.bz2 &&\
64 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 &&\
19f0b0b9 65 cd / && rm -rf /jemalloc-new
fdc85645 66
f77ca5a8 67RUN echo 'gem: --no-document' >> /usr/local/etc/gemrc &&\
71c3c655 68 mkdir /src && cd /src && git clone https://github.com/sstephenson/ruby-build.git &&\
84bb8fe7 69 cd /src/ruby-build && ./install.sh &&\
ff9ddabe 70 cd / && rm -rf /src/ruby-build && (ruby-build 2.6.3 /usr/local)
71c3c655 71
350cc62e
SS
72RUN gem update --system
73
9da5d8ab 74RUN gem install bundler --force &&\
ff9ddabe 75 rm -rf /usr/local/share/ri/2.6.3/system &&\
fb62e7aa 76 cd / && git clone https://github.com/discourse/pups.git
71c3c655 77
d5c4bf28
DU
78ADD install-redis /tmp/install-redis
79RUN /tmp/install-redis
80
8c9edf52
S
81ADD install-imagemagick /tmp/install-imagemagick
82RUN /tmp/install-imagemagick
83
71c3c655 84# Validate install
fc699958 85RUN ruby -Eutf-8 -e "v = \`convert -version\`; %w{png tiff jpeg freetype}.each { |f| unless v.include?(f); STDERR.puts('no ' + f + ' support in imagemagick'); exit(-1); end }"
71c3c655 86
fdc85645
S
87ADD install-pngcrush /tmp/install-pngcrush
88RUN /tmp/install-pngcrush
89
90ADD install-gifsicle /tmp/install-gifsicle
91RUN /tmp/install-gifsicle
92
93ADD install-pngquant /tmp/install-pngquant
94RUN /tmp/install-pngquant
5d6f9ed2 95
214fd2f0
S
96# This tool allows us to disable huge page support for our current process
97# since the flag is preserved through forks and execs it can be used on any
98# process
99ADD thpoff.c /src/thpoff.c
100RUN gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c
101
05a13f9e 102# clean up for docker squash
536ca9dd
S
103RUN rm -fr /usr/share/man &&\
104 rm -fr /usr/share/doc &&\
105 rm -fr /usr/share/vim/vim74/tutor &&\
106 rm -fr /usr/share/vim/vim74/doc &&\
107 rm -fr /usr/share/vim/vim74/lang &&\
108 rm -fr /usr/local/share/doc &&\
109 rm -fr /usr/local/share/ruby-build &&\
110 rm -fr /root/.gem &&\
dc7a8ede
S
111 rm -fr /root/.npm &&\
112 rm -fr /tmp/* &&\
113 rm -fr /usr/share/vim/vim74/spell/en*
114
536ca9dd
S
115
116# this can probably be done, but I worry that people changing PG locales will have issues
117# cd /usr/share/locale && rm -fr `ls -d */ | grep -v en`
118
536ca9dd 119RUN mkdir -p /etc/runit/3.d
23022c1d
MB
120
121ADD runit-1 /etc/runit/1
122ADD runit-1.d-cleanup-pids /etc/runit/1.d/cleanup-pids
b8dfc9a7 123ADD runit-1.d-anacron /etc/runit/1.d/anacron
573617ea 124ADD runit-1.d-00-fix-var-logs /etc/runit/1.d/00-fix-var-logs
23022c1d 125ADD runit-2 /etc/runit/2
074f2b6a
S
126ADD runit-3 /etc/runit/3
127ADD boot /sbin/boot
be82e068
S
128
129ADD cron /etc/service/cron/run
130ADD rsyslog /etc/service/rsyslog/run
089e57a2 131ADD cron.d_anacron /etc/cron.d/anacron
67446876
RSS
132
133# Discourse specific bits
134RUN useradd discourse -s /bin/bash -m -U &&\
135 mkdir -p /var/www &&\
136 cd /var/www &&\
137 git clone https://github.com/discourse/discourse.git &&\
138 cd discourse &&\
139 git remote set-branches --add origin tests-passed &&\
140 chown -R discourse:discourse /var/www/discourse &&\
141 cd /var/www/discourse &&\
b8866fb9 142 sudo -u discourse bundle install --deployment --jobs 4 --without test development &&\
cac4e5c6 143 bundle exec rake maxminddb:get &&\
67446876 144 find /var/www/discourse/vendor/bundle -name tmp -type d -exec rm -rf {} +