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