Skip to content

Commit ecec2d4

Browse files
committed
clean up debian dockerfile targets
1 parent f950d55 commit ecec2d4

File tree

1 file changed

+45
-37
lines changed

1 file changed

+45
-37
lines changed

build/Dockerfile

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -286,43 +286,54 @@ RUN --mount=type=bind,from=alpine-fips-3.19,target=/tmp/fips/ \
286286
agent.sh
287287

288288

289-
############################################# Base image for Debian with NGINX Plus #############################################
290-
FROM debian:12-slim@sha256:1209d8fd77def86ceb6663deef7956481cc6c14a25e1e64daec12c0ceffcc19d AS debian-plus
289+
############################################# Base image for Debian with NGINX Plus only #############################################
290+
FROM debian:12-slim@sha256:1209d8fd77def86ceb6663deef7956481cc6c14a25e1e64daec12c0ceffcc19d AS debian-plus-only
291291
ARG NGINX_PLUS_VERSION
292292

293293
ENV NGINX_VERSION=${NGINX_PLUS_VERSION}
294294

295295
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
296296
RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode=0644 \
297297
--mount=type=secret,id=nginx-repo.key,dst=/etc/ssl/nginx/nginx-repo.key,mode=0644 \
298-
--mount=type=bind,from=opentracing-lib,target=/tmp/ot/ \
299298
--mount=type=bind,from=nginx-files,src=nginx_signing.key,target=/tmp/nginx_signing.key \
300-
--mount=type=bind,from=nginx-files,src=app-protect-security-updates.key,target=/tmp/app-protect-security-updates.key \
301299
--mount=type=bind,from=nginx-files,src=90pkgs-nginx,target=/etc/apt/apt.conf.d/90pkgs-nginx \
302300
--mount=type=bind,from=nginx-files,src=debian-plus-12.sources,target=/tmp/nginx-plus.sources \
303-
--mount=type=bind,from=nginx-files,src=debian-agentv3-12.sources,target=/etc/apt/sources.list.d/nginx-agent.sources \
304-
--mount=type=bind,from=nginx-files,src=agent.sh,target=/usr/local/bin/agent.sh \
305301
--mount=type=bind,from=nginx-files,src=tracking.info,target=/tmp/nginx/reporting/tracking.info \
306302
apt-get update \
307303
&& apt-get install --no-install-recommends --no-install-suggests -y gpg ca-certificates libcap2-bin libcurl4 \
308304
&& groupadd --system --gid 101 nginx \
309305
&& useradd --system --gid nginx --no-create-home --home-dir /nonexistent --comment "nginx user" --shell /bin/false --uid 101 nginx \
310306
&& gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg /tmp/nginx_signing.key \
311-
&& gpg --dearmor -o /usr/share/keyrings/app-protect-archive-keyring.gpg /tmp/app-protect-security-updates.key \
312307
&& cp /tmp/nginx-plus.sources /etc/apt/sources.list.d/nginx-plus.sources \
313308
&& apt-get update \
314-
&& apt-get install --no-install-recommends --no-install-suggests -y nginx-plus nginx-plus-module-njs nginx-plus-module-opentracing nginx-plus-module-fips-check nginx-agent \
309+
&& apt-get install --no-install-recommends --no-install-suggests -y nginx-plus nginx-plus-module-njs nginx-plus-module-opentracing nginx-plus-module-fips-check \
315310
&& apt-get purge --auto-remove -y gpg \
316-
&& cp -av /tmp/ot/usr/local/lib/libjaegertracing*so* /tmp/ot/usr/local/lib/libzipkin*so* /tmp/ot/usr/local/lib/libdd*so* /tmp/ot/usr/local/lib/libyaml*so* /usr/local/lib/ \
317311
&& mkdir -p /etc/nginx/reporting/ \
318312
&& cp -av /tmp/nginx/reporting/tracking.info /etc/nginx/reporting/tracking.info \
319-
&& ldconfig \
320-
&& agent.sh \
321313
&& rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx-plus.sources
322314

323315

316+
############################################# Base image for Debian with NGINX Plus #############################################
317+
FROM debian-plus-only AS debian-plus
318+
ARG NGINX_PLUS_VERSION
319+
320+
ENV NGINX_VERSION=${NGINX_PLUS_VERSION}
321+
322+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
323+
RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode=0644 \
324+
--mount=type=secret,id=nginx-repo.key,dst=/etc/ssl/nginx/nginx-repo.key,mode=0644 \
325+
--mount=type=bind,from=nginx-files,src=90pkgs-nginx,target=/etc/apt/apt.conf.d/90pkgs-nginx \
326+
--mount=type=bind,from=nginx-files,src=debian-agentv3-12.sources,target=/tmp/nginx-agent.sources \
327+
--mount=type=bind,from=nginx-files,src=agent.sh,target=/usr/local/bin/agent.sh \
328+
apt-get update \
329+
&& cp /tmp/nginx-agent.sources /etc/apt/sources.list.d/nginx-agent.sources \
330+
&& apt-get update \
331+
&& apt-get install --no-install-recommends --no-install-suggests -y nginx-agent \
332+
&& agent.sh \
333+
&& rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx-agent.sources
334+
324335
############################################# Base image for Debian with NGINX Plus and App Protect WAF/DoS #############################################
325-
FROM debian-plus AS debian-plus-nap
336+
FROM debian-plus-only AS debian-plus-nap
326337
ARG NAP_MODULES
327338
ARG NGINX_PLUS_VERSION
328339

@@ -332,42 +343,39 @@ RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode
332343
--mount=type=secret,id=nginx-repo.key,dst=/etc/ssl/nginx/nginx-repo.key,mode=0644 \
333344
--mount=type=bind,from=opentracing-lib,target=/tmp/ot/ \
334345
--mount=type=bind,from=nginx-files,src=nginx_signing.key,target=/tmp/nginx_signing.key \
346+
--mount=type=bind,from=nginx-files,src=app-protect-security-updates.key,target=/tmp/app-protect-security-updates.key \
335347
--mount=type=bind,from=nginx-files,src=90pkgs-nginx,target=/etc/apt/apt.conf.d/90pkgs-nginx \
336348
--mount=type=bind,from=nginx-files,src=nap-waf-12.sources,target=/tmp/app-protect.sources \
337349
--mount=type=bind,from=nginx-files,src=nap-dos-12.sources,target=/tmp/app-protect-dos.sources \
338-
--mount=type=bind,from=nginx-files,src=debian-agent-12.sources,target=/etc/apt/sources.list.d/nginx-agent.sources \
350+
--mount=type=bind,from=nginx-files,src=debian-agent-12.sources,target=/tmp/nginx-agent.sources \
339351
--mount=type=bind,from=nginx-files,src=agent.sh,target=/usr/local/bin/agent.sh \
340352
--mount=type=bind,from=nginx-files,src=nap-waf.sh,target=/usr/local/bin/nap-waf.sh \
341353
--mount=type=bind,from=nginx-files,src=nap-dos.sh,target=/usr/local/bin/nap-dos.sh \
342354
--mount=type=bind,from=nginx-files,src=tracking.info,target=/tmp/nginx/reporting/tracking.info \
343355
mkdir -p /etc/nginx/reporting/ && cp -av /tmp/nginx/reporting/tracking.info /etc/nginx/reporting/tracking.info \
344356
&& if [ -z "${NAP_MODULES##*waf*}" ]; then \
345-
cp /tmp/app-protect.sources /etc/apt/sources.list.d/app-protect.sources; \
346-
fi \
347-
&& if [ -z "${NAP_MODULES##*dos*}" ]; then \
348-
cp /tmp/app-protect-dos.sources /etc/apt/sources.list.d/app-protect-dos.sources; \
349-
fi \
357+
apt-get update \
358+
&& apt-get install --no-install-recommends --no-install-suggests -y gpg \
359+
&& gpg --dearmor -o /usr/share/keyrings/app-protect-archive-keyring.gpg /tmp/app-protect-security-updates.key \
360+
&& cp /tmp/app-protect.sources /etc/apt/sources.list.d/app-protect.sources \
361+
&& cp /tmp/nginx-agent.sources /etc/apt/sources.list.d/nginx-agent.sources \
350362
&& apt-get update \
351-
&& apt-get install --no-install-recommends --no-install-suggests -y nginx-agent \
352-
&& if [ -z "${NAP_MODULES##*waf*}" ]; then \
353-
apt-get install --no-install-recommends --no-install-suggests -y app-protect app-protect-attack-signatures app-protect-threat-campaigns; \
354-
fi \
355-
&& if [ -z "${NAP_MODULES##*dos*}" ]; then \
356-
apt-get install --no-install-recommends --no-install-suggests -y app-protect-dos; \
357-
fi \
358-
&& if [ -z "${NAP_MODULES##*waf*}" ]; then \
359-
rm -f /etc/apt/sources.list.d/app-protect.sources; \
363+
&& apt-get install --no-install-recommends --no-install-suggests -y app-protect app-protect-attack-signatures app-protect-threat-campaigns nginx-agent \
364+
&& rm -f /etc/apt/sources.list.d/app-protect.sources /etc/apt/sources.list.d/nginx-agent.sources \
365+
&& nap-waf.sh \
366+
&& agent.sh; \
360367
fi \
361368
&& if [ -z "${NAP_MODULES##*dos*}" ]; then \
362-
rm -f /etc/apt/sources.list.d/app-protect-dos.sources; \
369+
cp /tmp/app-protect-dos.sources /etc/apt/sources.list.d/app-protect-dos.sources \
370+
&& apt-get update \
371+
&& apt-get install --no-install-recommends --no-install-suggests -y app-protect-dos \
372+
&& rm -f /etc/apt/sources.list.d/app-protect-dos.sources \
373+
&& nap-dos.sh; \
363374
fi \
364-
&& rm -rf /var/lib/apt/lists/* \
365-
&& if [ -z "${NAP_MODULES##*waf*}" ]; then nap-waf.sh; fi \
366-
&& agent.sh \
367-
&& if [ -z "${NAP_MODULES##*dos*}" ]; then nap-dos.sh; fi
375+
&& rm -rf /var/lib/apt/lists/*
368376

369377
############################################# Base image for Debian with NGINX Plus and App Protect WAFv5 #############################################
370-
FROM debian-plus AS debian-plus-nap-v5
378+
FROM debian-plus-only AS debian-plus-nap-v5
371379
ARG NAP_MODULES
372380
ARG NGINX_PLUS_VERSION
373381

@@ -382,10 +390,10 @@ RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/ssl/nginx/nginx-repo.crt,mode
382390
--mount=type=bind,from=nginx-files,src=debian-agent-12.sources,target=/etc/apt/sources.list.d/nginx-agent.sources \
383391
--mount=type=bind,from=nginx-files,src=tracking.info,target=/tmp/nginx/reporting/tracking.info \
384392
mkdir -p /etc/nginx/reporting/ && cp -av /tmp/nginx/reporting/tracking.info /etc/nginx/reporting/tracking.info \
385-
apt-get update \
386-
apt-get install --no-install-recommends --no-install-suggests -y \
387-
nginx-agent app-protect-module-plus=33+5.264* nginx-plus-module-appprotect=33+5.264*; \
388-
nap-waf.sh \
393+
&& apt-get update \
394+
&& apt-get install --no-install-recommends --no-install-suggests -y gpg \
395+
nginx-agent app-protect-module-plus=33+5.264* nginx-plus-module-appprotect=33+5.264* app-protect-plugin=6.9.0* \
396+
&& nap-waf.sh \
389397
&& apt-get purge --auto-remove -y gpg \
390398
&& agent.sh
391399

0 commit comments

Comments
 (0)