@@ -8,126 +8,207 @@ ARG DEBIAN_RELEASE
8
8
ENV PG_MAJOR=13 \
9
9
RUBY_ALLOCATOR=/usr/lib/libjemalloc.so \
10
10
LEFTHOOK=0 \
11
- DEBIAN_RELEASE=${DEBIAN_RELEASE}
11
+ DEBIAN_RELEASE=${DEBIAN_RELEASE} \
12
+ LC_ALL=en_US.UTF-8 \
13
+ LANG=en_US.UTF-8 \
14
+ LANGUAGE=en_US.UTF-8
12
15
13
16
# LABEL maintainer="Sam Saffron \"https://twitter.com/samsaffron\""
14
17
15
- # Ensures that the gid and uid of the following users are consistent to avoid permission issues on directories in the
16
- # mounted volumes.
17
- RUN groupadd --gid 104 postgres &&\
18
- useradd --uid 101 --gid 104 --home /var/lib/postgresql --shell /bin/bash -c "PostgreSQL administrator,,," postgres &&\
19
- groupadd --gid 106 redis &&\
20
- useradd --uid 103 --gid 106 --home /var/lib/redis --shell /usr/sbin/nologin redis &&\
21
- groupadd --gid 1000 discourse &&\
22
- useradd --uid 1000 --gid 1000 -m --shell /bin/bash discourse
23
-
24
- RUN echo 2.0.`date +%Y%m%d` > /VERSION
25
- RUN echo "deb http://deb.debian.org/debian ${DEBIAN_RELEASE}-backports main" > "/etc/apt/sources.list.d/${DEBIAN_RELEASE}-backports.list"
26
- RUN echo "debconf debconf/frontend select Teletype" | debconf-set-selections
27
- RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install gnupg sudo curl fping
28
- RUN sh -c "fping proxy && echo 'Acquire { Retries \" 0\" ; HTTP { Proxy \" http://proxy:3128\" ;}; };' > /etc/apt/apt.conf.d/40proxy && apt-get update || true"
29
- RUN apt-mark hold initscripts
30
- RUN apt-get -y upgrade
31
-
32
- RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales locales-all
33
- ENV LC_ALL en_US.UTF-8
34
- ENV LANG en_US.UTF-8
35
- ENV LANGUAGE en_US.UTF-8
36
-
37
- RUN install -d /usr/share/postgresql-common/pgdg &&\
38
- curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc &&\
39
- echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${DEBIAN_RELEASE}-pgdg main" > /etc/apt/sources.list.d/pgdg.list
40
-
41
- RUN curl --silent --location https://deb.nodesource.com/setup_18.x | sudo bash -
42
- RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
43
- RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list
44
- RUN apt-get -y update
45
- # install these without recommends to avoid pulling in e.g.
46
- # X11 libraries, mailutils
47
- RUN DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends git rsyslog logrotate cron ssh-client less
48
- RUN DEBIAN_FRONTEND=noninteractive apt-get -y install autoconf build-essential ca-certificates rsync \
49
- libxslt-dev libcurl4-openssl-dev \
50
- libssl-dev libyaml-dev libtool \
51
- libpcre3 libpcre3-dev zlib1g zlib1g-dev \
52
- libxml2-dev gawk parallel \
53
- postgresql-${PG_MAJOR} postgresql-client \
54
- postgresql-contrib-${PG_MAJOR} libpq-dev postgresql-${PG_MAJOR}-pgvector \
55
- libreadline-dev anacron wget \
56
- psmisc whois brotli libunwind-dev \
57
- libtcmalloc-minimal4 cmake \
58
- pngcrush pngquant ripgrep poppler-utils
59
- RUN sed -i -e 's/start -q anacron/anacron -s/' /etc/cron.d/anacron
60
- RUN sed -i.bak 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf
61
- RUN sed -i.bak 's/module(load="imklog")/#module(load="imklog")/' /etc/rsyslog.conf
62
- RUN dpkg-divert --local --rename --add /sbin/initctl
63
- RUN sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl"
64
- RUN cd / &&\
65
- DEBIAN_FRONTEND=noninteractive apt-get -y install runit socat &&\
66
- mkdir -p /etc/runit/1.d &&\
67
- apt-get clean &&\
68
- rm -f /etc/apt/apt.conf.d/40proxy &&\
69
- locale-gen en_US &&\
70
- DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs yarn &&\
71
- npm install -g terser uglify-js pnpm
72
-
73
18
ADD install-imagemagick /tmp/install-imagemagick
74
- RUN /tmp/install-imagemagick
75
-
76
19
ADD install-jemalloc /tmp/install-jemalloc
77
- RUN /tmp/install-jemalloc
78
-
79
20
# From https://nginx.org/en/pgp_keys.html
80
21
ADD nginx_public_keys.key /tmp/nginx_public_keys.key
81
22
ADD install-nginx /tmp/install-nginx
82
-
83
- RUN gpg --import /tmp/nginx_public_keys.key &&\
84
- rm /tmp/nginx_public_keys.key &&\
85
- /tmp/install-nginx
86
-
87
- ADD install-redis /tmp/install-redis
88
- RUN /tmp/install-redis
89
-
90
23
ADD install-oxipng /tmp/install-oxipng
91
- RUN /tmp/install-oxipng
92
-
93
- RUN echo 'gem: --no-document' >> /usr/local/etc/gemrc &&\
94
- gem update --system
95
-
96
- RUN gem install pups --force &&\
97
- mkdir -p /pups/bin/ &&\
98
- ln -s /usr/local/bin/pups /pups/bin/pups
99
-
24
+ ADD install-redis /tmp/install-redis
100
25
# This tool allows us to disable huge page support for our current process
101
26
# since the flag is preserved through forks and execs it can be used on any
102
27
# process
103
28
ADD thpoff.c /src/thpoff.c
104
- RUN gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c
105
29
106
- # clean up for docker squash
107
- RUN rm -fr /usr/share/man &&\
108
- rm -fr /usr/share/doc &&\
109
- rm -fr /usr/share/vim/vim74/doc &&\
110
- rm -fr /usr/share/vim/vim74/lang &&\
111
- rm -fr /usr/share/vim/vim74/spell/en* &&\
112
- rm -fr /usr/share/vim/vim74/tutor &&\
113
- rm -fr /usr/local/share/doc &&\
114
- rm -fr /usr/local/share/ri &&\
115
- rm -fr /var/lib/apt/lists/* &&\
116
- rm -fr /root/.gem &&\
117
- rm -fr /root/.npm &&\
118
- rm -fr /tmp/*
119
-
120
- # this can probably be done, but I worry that people changing PG locales will have issues
121
- # cd /usr/share/locale && rm -fr `ls -d */ | grep -v en`
122
-
123
- # this is required for aarch64 which uses buildx
124
- # see https://github.com/docker/buildx/issues/150
125
- RUN rm -f /etc/service
126
-
127
- COPY etc/ /etc
30
+ RUN set -eux; \
31
+ # Ensures that the gid and uid of the following users are consistent to avoid permission issues on directories in the
32
+ # mounted volumes.
33
+ groupadd --gid 104 postgres; \
34
+ useradd --uid 101 --gid 104 --home /var/lib/postgresql --shell /bin/bash -c "PostgreSQL administrator,,," postgres; \
35
+ groupadd --gid 106 redis; \
36
+ useradd --uid 103 --gid 106 --home /var/lib/redis --shell /usr/sbin/nologin redis; \
37
+ groupadd --gid 1000 discourse; \
38
+ useradd --uid 1000 --gid 1000 -m --shell /bin/bash discourse; \
39
+ \
40
+ echo 2.0.`date +%Y%m%d` > /VERSION; \
41
+ echo "deb http://deb.debian.org/debian ${DEBIAN_RELEASE}-backports main" > "/etc/apt/sources.list.d/${DEBIAN_RELEASE}-backports.list" ; \
42
+ echo "debconf debconf/frontend select Teletype" | debconf-set-selections; \
43
+ apt-get update; \
44
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends sudo curl; \
45
+ install -d /usr/share/postgresql-common/pgdg; \
46
+ curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc; \
47
+ echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt ${DEBIAN_RELEASE}-pgdg main" > /etc/apt/sources.list.d/pgdg.list; \
48
+ curl --silent --location https://deb.nodesource.com/setup_18.x | sudo bash -; \
49
+ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -; \
50
+ echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list; \
51
+ apt-mark hold initscripts; \
52
+ apt-get update; \
53
+ apt-get -y upgrade; \
54
+ \
55
+ # Dependencies required to run Discourse
56
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
57
+ locales \
58
+ locales-all \
59
+ git \
60
+ rsyslog \
61
+ logrotate \
62
+ cron \
63
+ ssh-client \
64
+ less \
65
+ ca-certificates \
66
+ rsync \
67
+ libxslt-dev \
68
+ libcurl4-openssl-dev \
69
+ libssl-dev \
70
+ libyaml-dev \
71
+ libtool \
72
+ libpcre3 \
73
+ libpcre3-dev \
74
+ zlib1g \
75
+ zlib1g-dev \
76
+ libxml2-dev \
77
+ gawk \
78
+ parallel \
79
+ postgresql-${PG_MAJOR} \
80
+ postgresql-client \
81
+ postgresql-contrib-${PG_MAJOR} \
82
+ libpq-dev \
83
+ postgresql-${PG_MAJOR}-pgvector \
84
+ libreadline-dev \
85
+ anacron \
86
+ psmisc \
87
+ whois \
88
+ brotli \
89
+ libunwind-dev \
90
+ libtcmalloc-minimal4 \
91
+ ripgrep \
92
+ poppler-utils \
93
+ runit \
94
+ socat \
95
+ nodejs \
96
+ yarn \
97
+ # START Nginx
98
+ nginx-common \
99
+ # END Nginx
100
+ # START ImageMagick
101
+ pngcrush \
102
+ pngquant \
103
+ libde265-0 \
104
+ libde265-dev \
105
+ libjpeg62-turbo \
106
+ libjpeg62-turbo-dev \
107
+ libwebp7 \
108
+ x265 \
109
+ libx265-dev \
110
+ libtool \
111
+ libpng16-16 \
112
+ libpng-dev \
113
+ libwebp-dev \
114
+ libgomp1 \
115
+ libwebpmux3 \
116
+ libwebpdemux2 \
117
+ ghostscript \
118
+ libxml2-dev \
119
+ libxml2-utils \
120
+ librsvg2-dev \
121
+ libltdl7-dev \
122
+ libbz2-dev \
123
+ gsfonts \
124
+ libtiff-dev \
125
+ libfreetype6-dev \
126
+ libjpeg-dev \
127
+ libheif1 \
128
+ libheif-dev \
129
+ libaom-dev \
130
+ # END ImageMagick
131
+ ; \
132
+ savedAptMark="$(apt-mark showmanual)" ; \
133
+ # Dependencies required to build packages. These packages are automatically removed
134
+ # at the end of the RUN step.
135
+ DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
136
+ wget \
137
+ gcc \
138
+ g++ \
139
+ make \
140
+ cmake \
141
+ autoconf \
142
+ automake \
143
+ libtool \
144
+ pkg-config \
145
+ autoconf \
146
+ yasm \
147
+ ; \
148
+ sed -i -e 's/start -q anacron/anacron -s/' /etc/cron.d/anacron; \
149
+ sed -i.bak 's/$ModLoad imklog/#$ModLoad imklog/' /etc/rsyslog.conf; \
150
+ sed -i.bak 's/module(load="imklog")/#module(load="imklog")/' /etc/rsyslog.conf; \
151
+ dpkg-divert --local --rename --add /sbin/initctl; \
152
+ sh -c "test -f /sbin/initctl || ln -s /bin/true /sbin/initctl" ; \
153
+ mkdir -p /etc/runit/1.d; \
154
+ rm -f /etc/apt/apt.conf.d/40proxy; \
155
+ locale-gen en_US; \
156
+ npm install -g terser uglify-js pnpm; \
157
+ \
158
+ # Installs ImageMagick
159
+ /tmp/install-imagemagick; \
160
+ # Installs JeMalloc
161
+ /tmp/install-jemalloc; \
162
+ \
163
+ # Installs Nginx
164
+ gpg --import /tmp/nginx_public_keys.key; \
165
+ rm /tmp/nginx_public_keys.key; \
166
+ /tmp/install-nginx; \
167
+ # Installs Redis
168
+ /tmp/install-redis; \
169
+ # Installs Oxipng
170
+ /tmp/install-oxipng; \
171
+ echo 'gem: --no-document' >> /usr/local/etc/gemrc; \
172
+ gem update --system; \
173
+ gem install pups --force; \
174
+ mkdir -p /pups/bin/; \
175
+ ln -s /usr/local/bin/pups /pups/bin/pups; \
176
+ gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c; \
177
+ \
178
+ # Discourse specific bits
179
+ install -dm 0755 -o discourse -g discourse /var/www/discourse; \
180
+ sudo -u discourse git clone --filter=tree:0 https://github.com/discourse/discourse.git /var/www/discourse; \
181
+ gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' /var/www/discourse/Gemfile.lock); \
182
+ \
183
+ # Clean up
184
+ rm -fr /usr/share/man; \
185
+ rm -fr /usr/share/doc; \
186
+ rm -fr /usr/share/vim/vim74/doc; \
187
+ rm -fr /usr/share/vim/vim74/lang; \
188
+ rm -fr /usr/share/vim/vim74/spell/en*; \
189
+ rm -fr /usr/share/vim/vim74/tutor; \
190
+ rm -fr /usr/local/share/doc; \
191
+ rm -fr /usr/local/share/ri; \
192
+ rm -fr /var/lib/apt/lists/*; \
193
+ rm -fr /root/.gem; \
194
+ rm -fr /root/.npm; \
195
+ rm -fr /tmp/*; \
196
+ apt-mark auto '.*' > /dev/null; \
197
+ apt-mark manual $savedAptMark > /dev/null; \
198
+ find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
199
+ | awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); printf "*%s\n ", so }' \
200
+ | sort -u \
201
+ | xargs -r dpkg-query --search \
202
+ | cut -d: -f1 \
203
+ | sort -u \
204
+ | xargs -r apt-mark manual \
205
+ ; \
206
+ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
207
+ apt-get clean; \
208
+ \
209
+ # this is required for aarch64 which uses buildx
210
+ # see https://github.com/docker/buildx/issues/150
211
+ rm -f /etc/service
212
+
213
+ COPY etc/ /etc
128
214
COPY sbin/ /sbin
129
-
130
- # Discourse specific bits
131
- RUN install -dm 0755 -o discourse -g discourse /var/www/discourse &&\
132
- sudo -u discourse git clone --filter=tree:0 https://github.com/discourse/discourse.git /var/www/discourse &&\
133
- gem install bundler --conservative -v $(awk '/BUNDLED WITH/ { getline; gsub(/ /,""); print $0 }' /var/www/discourse/Gemfile.lock)
0 commit comments