Skip to content

Commit d3f63b4

Browse files
committed
Move nginx installation into another build step
Avoids polluting the main image with nginx's build dependencies
1 parent 5ed07ec commit d3f63b4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

image/base/Dockerfile

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ FROM builder AS imagemagick_builder
1717
ADD install-imagemagick /tmp/install-imagemagick
1818
RUN /tmp/install-imagemagick
1919

20+
FROM builder AS nginx_builder
21+
# From https://nginx.org/en/pgp_keys.html
22+
ADD nginx_public_keys.key /tmp/nginx_public_keys.key
23+
ADD install-nginx /tmp/install-nginx
24+
RUN gpg --import /tmp/nginx_public_keys.key &&\
25+
rm /tmp/nginx_public_keys.key &&\
26+
/tmp/install-nginx
27+
2028
FROM discourse/ruby:3.3.6-${DEBIAN_RELEASE}-slim AS discourse_dependencies
2129

2230
ARG DEBIAN_RELEASE
@@ -91,6 +99,8 @@ RUN sed -i "s/^# $LANG/$LANG/" /etc/locale.gen; \
9199
RUN --mount=type=tmpfs,target=/root/.npm \
92100
npm install -g terser uglify-js pnpm
93101

102+
COPY --from=nginx_builder /usr/sbin/nginx /usr/sbin
103+
94104
# Copy binary and configuration files for magick
95105
COPY --from=imagemagick_builder /usr/local/bin/magick /usr/local/bin/magick
96106
COPY --from=imagemagick_builder /usr/local/etc/ImageMagick-7 /usr/local/etc/ImageMagick-7
@@ -113,14 +123,6 @@ RUN ln -s /usr/local/bin/magick /usr/local/bin/animate &&\
113123
ADD install-jemalloc /tmp/install-jemalloc
114124
RUN /tmp/install-jemalloc
115125

116-
# From https://nginx.org/en/pgp_keys.html
117-
ADD nginx_public_keys.key /tmp/nginx_public_keys.key
118-
ADD install-nginx /tmp/install-nginx
119-
120-
RUN gpg --import /tmp/nginx_public_keys.key &&\
121-
rm /tmp/nginx_public_keys.key &&\
122-
/tmp/install-nginx
123-
124126
ADD install-redis /tmp/install-redis
125127
RUN /tmp/install-redis
126128

0 commit comments

Comments
 (0)