Skip to content

Commit 9455516

Browse files
DEV: add separate builders for thpoff, jemalloc, and oxipng
Separate out builders for thpoff, jemalloc and oxipng/jhead Copy over the results of all libraries to reduce dependencies for base image needing build tools.
1 parent e957176 commit 9455516

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

image/base/Dockerfile

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,23 @@ FROM builder AS nginx_builder
2727
ADD nginx_public_keys.key /tmp/nginx_public_keys.key
2828
ADD install-nginx /tmp/install-nginx
2929
RUN gpg --import /tmp/nginx_public_keys.key &&\
30-
rm /tmp/nginx_public_keys.key &&\
31-
/tmp/install-nginx
30+
rm /tmp/nginx_public_keys.key &&\
31+
/tmp/install-nginx
32+
33+
FROM builder AS thpoff_builder
34+
# This tool allows us to disable huge page support for our current process
35+
# since the flag is preserved through forks and execs it can be used on any
36+
# process
37+
ADD thpoff.c /src/thpoff.c
38+
RUN gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c
39+
40+
FROM builder AS jemalloc_builder
41+
ADD install-jemalloc /tmp/install-jemalloc
42+
RUN /tmp/install-jemalloc
43+
44+
FROM builder AS oxipng_builder
45+
ADD install-oxipng /tmp/install-oxipng
46+
RUN /tmp/install-oxipng
3247

3348
FROM discourse/ruby:${RUBY_VERSION}-${DEBIAN_RELEASE}-slim AS discourse_dependencies
3449

@@ -70,6 +85,8 @@ RUN --mount=type=tmpfs,target=/var/log \
7085
ghostscript libjbig0 libtiff6 libpng16-16 libfontconfig1 \
7186
libwebpdemux2 libwebpmux3 libxext6 librsvg2-2 libgomp1 \
7287
fonts-urw-base35 libheif1/${DEBIAN_RELEASE}-backports \
88+
# oxipng dependencies \
89+
advancecomp jpegoptim libjpeg-turbo-progs \
7390
# nginx runtime dependencies \
7491
nginx-common && \
7592
# install these without recommends to avoid pulling in e.g.
@@ -125,24 +142,18 @@ RUN ln -s /usr/local/bin/magick /usr/local/bin/animate &&\
125142
ln -s /usr/local/bin/magick /usr/local/bin/stream &&\
126143
test $(magick -version | grep -o -e png -e tiff -e jpeg -e freetype -e heic -e webp | wc -l) -eq 6
127144

128-
ADD install-jemalloc /tmp/install-jemalloc
129-
RUN /tmp/install-jemalloc
145+
COPY --from=thpoff_builder /usr/local/sbin/thpoff /usr/local/sbin
146+
COPY --from=jemalloc_builder /usr/lib/libjemalloc.so.2 /usr/lib
147+
RUN ln -s /usr/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so
148+
COPY --from=oxipng_builder /usr/local/bin/jhead /usr/local/bin
149+
COPY --from=oxipng_builder /usr/local/bin/oxipng /usr/local/bin
130150

131151
ADD install-redis /tmp/install-redis
132152

133-
ADD install-oxipng /tmp/install-oxipng
134-
RUN /tmp/install-oxipng
135-
136153
RUN gem install pups --force &&\
137154
mkdir -p /pups/bin/ &&\
138155
ln -s /usr/local/bin/pups /pups/bin/pups
139156

140-
# This tool allows us to disable huge page support for our current process
141-
# since the flag is preserved through forks and execs it can be used on any
142-
# process
143-
ADD thpoff.c /src/thpoff.c
144-
RUN gcc -o /usr/local/sbin/thpoff /src/thpoff.c && rm /src/thpoff.c
145-
146157
# this is required for aarch64 which uses buildx
147158
# see https://github.com/docker/buildx/issues/150
148159
RUN rm -f /etc/service

0 commit comments

Comments
 (0)