|
1 |
| -FROM debian:bookworm-slim@sha256:67f3931ad8cb1967beec602d8c0506af1e37e8d73c2a0b38b181ec5d8560d395 |
| 1 | +ARG RELEASE=bookworm |
| 2 | +FROM debian:${RELEASE}-slim@sha256:67f3931ad8cb1967beec602d8c0506af1e37e8d73c2a0b38b181ec5d8560d395 |
2 | 3 |
|
3 |
| -ENV NGINX_PLUS_VERSION 30-2 |
4 |
| -ENV NGINX_VERSION 1.25.1 |
5 |
| -ENV NJS_VERSION 30+0.8.0-1 |
6 |
| -ENV XSLT_VERSION 30-1 |
| 4 | +# NJS env vars |
| 5 | +ENV NGINX_VERSION=32 |
| 6 | +ENV NGINX_PKG_RELEASE=1~${RELEASE} |
| 7 | +ENV NJS_VERSION=0.8.4 |
| 8 | +ENV NJS_PKG_RELEASE=1~${RELEASE} |
7 | 9 |
|
8 |
| -ENV PROXY_CACHE_MAX_SIZE "10g" |
9 |
| -ENV PROXY_CACHE_INACTIVE "60m" |
10 |
| -ENV PROXY_CACHE_SLICE_SIZE "1m" |
11 |
| -ENV PROXY_CACHE_VALID_OK "1h" |
12 |
| -ENV PROXY_CACHE_VALID_NOTFOUND "1m" |
13 |
| -ENV PROXY_CACHE_VALID_FORBIDDEN "30s" |
14 |
| -ENV CORS_ENABLED 0 |
15 |
| -ENV CORS_ALLOW_PRIVATE_NETWORK_ACCESS "" |
16 |
| -ENV DIRECTORY_LISTING_PATH_PREFIX "" |
17 |
| -ENV STRIP_LEADING_DIRECTORY_PATH "" |
18 |
| -ENV PREFIX_LEADING_DIRECTORY_PATH "" |
| 10 | +# Proxy cache env vars |
| 11 | +ENV PROXY_CACHE_MAX_SIZE=10g |
| 12 | +ENV PROXY_CACHE_INACTIVE=60m |
| 13 | +ENV PROXY_CACHE_SLICE_SIZE=1m |
| 14 | +ENV PROXY_CACHE_VALID_OK=1h |
| 15 | +ENV PROXY_CACHE_VALID_NOTFOUND=1m |
| 16 | +ENV PROXY_CACHE_VALID_FORBIDDEN=30s |
19 | 17 |
|
20 |
| -COPY plus/etc/ssl /etc/ssl |
21 |
| -COPY plus/usr /usr |
| 18 | +# CORS env vars |
| 19 | +ENV CORS_ENABLED=0 |
| 20 | +ENV CORS_ALLOW_PRIVATE_NETWORK_ACCESS="" |
22 | 21 |
|
23 |
| -# Copy files from the OSS NGINX Docker container such that the container |
24 |
| -# startup is the same. |
25 |
| -COPY common/docker-entrypoint.sh /docker-entrypoint.sh |
26 |
| -COPY common/docker-entrypoint.d /docker-entrypoint.d/ |
27 |
| -COPY plus/docker-entrypoint.d /docker-entrypoint.d/ |
28 |
| -# Add NGINX Plus package repository keyring |
29 |
| -COPY plus/usr/share/keyrings/nginx-archive-keyring.gpg /usr/share/keyrings/nginx-archive-keyring.gpg |
| 22 | +# S3 proxy env vars |
| 23 | +ENV DIRECTORY_LISTING_PATH_PREFIX="" |
| 24 | +ENV STRIP_LEADING_DIRECTORY_PATH="" |
| 25 | +ENV PREFIX_LEADING_DIRECTORY_PATH="" |
30 | 26 |
|
31 |
| -RUN set -eux \ |
32 |
| - export DEBIAN_FRONTEND=noninteractive; \ |
33 |
| - # create nginx user/group first, to be consistent throughout docker variants |
34 |
| - addgroup --system --gid 101 nginx; \ |
35 |
| - adduser --system --disabled-login --ingroup nginx --no-create-home --home /nonexistent --gecos "nginx user" --shell /bin/false --uid 101 nginx; \ |
36 |
| - apt-get -qq update; \ |
37 |
| - apt-get -qq upgrade --yes; \ |
38 |
| - apt-get -qq install --yes \ |
39 |
| - ca-certificates \ |
40 |
| - curl \ |
41 |
| - libedit2; \ |
42 |
| - sh -a /usr/local/bin/add_nginx_plus_repo.sh; \ |
43 |
| - rm /usr/local/bin/add_nginx_plus_repo.sh; \ |
44 |
| - apt-get -qq update; \ |
45 |
| - export DISTRO_VERSION="$(grep '^VERSION_CODENAME=' /etc/os-release | awk -v FS='=' '{print $2}')" && \ |
46 |
| - apt-get -qq install --yes --no-install-recommends --no-install-suggests \ |
47 |
| - nginx-plus=${NGINX_PLUS_VERSION}~${DISTRO_VERSION} \ |
48 |
| - nginx-plus-module-njs=${NJS_VERSION}~${DISTRO_VERSION} \ |
49 |
| - nginx-plus-module-xslt=${XSLT_VERSION}~${DISTRO_VERSION} \ |
50 |
| - gettext-base; \ |
51 |
| - apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ |
52 |
| - rm -rf /etc/apt/sources.list.d/nginx-plus.list /var/lib/apt/lists/* /var/tmp/* /tmp/*; \ |
53 |
| - # forward request and error logs to docker log collector |
54 |
| - ln -sf /dev/stdout /var/log/nginx/access.log; \ |
55 |
| - ln -sf /dev/stderr /var/log/nginx/error.log; \ |
56 |
| - chmod -R -v +x /docker-entrypoint.sh /docker-entrypoint.d/*.sh |
| 27 | +# We create an NGINX Plus image based on the official NGINX Plus Dockerfiles (https://gist.github.com/nginx-gists/36e97fc87efb5cf0039978c8e41a34b5) and modify it by: |
| 28 | +# 1. Explicitly installing the version of njs coded in the environment variable above. |
| 29 | +# 2. Adding configuration files needed for proxying private S3 buckets. |
| 30 | +# 3. Adding a directory for proxied objects to be stored. |
| 31 | +# 4. Adding the entrypoint scripts found in the base NGINX OSS Docker image with a modified version that explicitly sets resolvers. |
57 | 32 |
|
58 |
| -ENTRYPOINT ["/docker-entrypoint.sh"] |
| 33 | +# Download your NGINX license certificate and key from the F5 customer portal (https://account.f5.com) and copy them to the build context |
| 34 | +RUN --mount=type=secret,id=nginx-crt,dst=nginx-repo.crt \ |
| 35 | + --mount=type=secret,id=nginx-key,dst=nginx-repo.key \ |
| 36 | + set -x \ |
| 37 | +# Create nginx user/group first, to be consistent throughout Docker variants |
| 38 | + && groupadd --system --gid 101 nginx \ |
| 39 | + && useradd --system --gid nginx --no-create-home --home /nonexistent --comment "nginx user" --shell /bin/false --uid 101 nginx \ |
| 40 | + && apt-get update \ |
| 41 | + && apt-get install --no-install-recommends --no-install-suggests -y ca-certificates gnupg2 lsb-release \ |
| 42 | + && \ |
| 43 | + NGINX_GPGKEYS="573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 8540A6F18833A80E9C1653A42FD21310B49F6B46 9E9BE90EACBCDE69FE9B204CBCDCD8A38D88A2B3"; \ |
| 44 | + NGINX_GPGKEY_PATH=/usr/share/keyrings/nginx-archive-keyring.gpg; \ |
| 45 | + export GNUPGHOME="$(mktemp -d)"; \ |
| 46 | + found=''; \ |
| 47 | + for NGINX_GPGKEY in $NGINX_GPGKEYS; do \ |
| 48 | + for server in \ |
| 49 | + hkp://keyserver.ubuntu.com:80 \ |
| 50 | + pgp.mit.edu \ |
| 51 | + ; do \ |
| 52 | + echo "Fetching GPG key $NGINX_GPGKEY from $server"; \ |
| 53 | + gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \ |
| 54 | + done; \ |
| 55 | + test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \ |
| 56 | + done; \ |
| 57 | + gpg1 --export "$NGINX_GPGKEYS" > "$NGINX_GPGKEY_PATH" ; \ |
| 58 | + rm -rf "$GNUPGHOME"; \ |
| 59 | + apt-get remove --purge --auto-remove -y gnupg2 && rm -rf /var/lib/apt/lists/* \ |
| 60 | +# Install the latest release of NGINX Plus and/or NGINX Plus modules (written and maintained by F5) |
| 61 | + && nginxPackages=" \ |
| 62 | + nginx-plus=${NGINX_VERSION}-${NGINX_PKG_RELEASE} \ |
| 63 | + nginx-plus-module-njs=${NGINX_VERSION}+${NJS_VERSION}-${NJS_PKG_RELEASE} \ |
| 64 | + nginx-plus-module-xslt=${NGINX_VERSION}-${NGINX_PKG_RELEASE} \ |
| 65 | + " \ |
| 66 | + && echo "Acquire::https::pkgs.nginx.com::Verify-Peer \"true\";" > /etc/apt/apt.conf.d/90nginx \ |
| 67 | + && echo "Acquire::https::pkgs.nginx.com::Verify-Host \"true\";" >> /etc/apt/apt.conf.d/90nginx \ |
| 68 | + && echo "Acquire::https::pkgs.nginx.com::SslCert \"/etc/ssl/nginx/nginx-repo.crt\";" >> /etc/apt/apt.conf.d/90nginx \ |
| 69 | + && echo "Acquire::https::pkgs.nginx.com::SslKey \"/etc/ssl/nginx/nginx-repo.key\";" >> /etc/apt/apt.conf.d/90nginx \ |
| 70 | + && echo "deb [signed-by=$NGINX_GPGKEY_PATH] https://pkgs.nginx.com/plus/debian `lsb_release -cs` nginx-plus\n" > /etc/apt/sources.list.d/nginx-plus.list \ |
| 71 | + && mkdir -p /etc/ssl/nginx \ |
| 72 | + && cat nginx-repo.crt > /etc/ssl/nginx/nginx-repo.crt \ |
| 73 | + && cat nginx-repo.key > /etc/ssl/nginx/nginx-repo.key \ |
| 74 | + && apt-get update \ |
| 75 | + && apt-get install --no-install-recommends --no-install-suggests -y $nginxPackages curl gettext-base \ |
| 76 | + && apt-get remove --purge -y lsb-release \ |
| 77 | + && apt-get remove --purge --auto-remove -y && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/nginx-plus.list \ |
| 78 | + && rm -rf /etc/apt/apt.conf.d/90nginx /etc/ssl/nginx \ |
| 79 | +# Forward request logs to Docker log collector |
| 80 | + && ln -sf /dev/stdout /var/log/nginx/access.log \ |
| 81 | + && ln -sf /dev/stderr /var/log/nginx/error.log |
59 | 82 |
|
60 | 83 | EXPOSE 80
|
61 | 84 |
|
62 | 85 | STOPSIGNAL SIGTERM
|
63 | 86 |
|
64 | 87 | CMD ["nginx", "-g", "daemon off;"]
|
65 | 88 |
|
66 |
| -# NGINX Docker image setup complete, everything below is specific for |
67 |
| -# the S3 Gateway use case. |
68 |
| - |
| 89 | +# Copy files from the OSS NGINX Docker container such that the container |
| 90 | +# startup is the same. |
69 | 91 | COPY plus/etc/nginx /etc/nginx
|
70 | 92 | COPY common/etc /etc
|
71 |
| -COPY common/docker-entrypoint.d/00-check-for-required-env.sh /docker-entrypoint.d/00-check-for-required-env.sh |
| 93 | +COPY common/docker-entrypoint.sh /docker-entrypoint.sh |
| 94 | +COPY common/docker-entrypoint.d /docker-entrypoint.d/ |
| 95 | +COPY plus/docker-entrypoint.d /docker-entrypoint.d/ |
| 96 | + |
| 97 | +RUN set -x \ |
| 98 | + && mkdir -p /var/cache/nginx/s3_proxy \ |
| 99 | + && chown nginx:nginx /var/cache/nginx/s3_proxy \ |
| 100 | + && chmod -R -v +x /docker-entrypoint.sh /docker-entrypoint.d/*.sh; |
72 | 101 |
|
73 |
| -RUN set -eux \ |
74 |
| - export DEBIAN_FRONTEND=noninteractive; \ |
75 |
| - mkdir -p /var/cache/nginx/s3_proxy; \ |
76 |
| - chown nginx:nginx /var/cache/nginx/s3_proxy; \ |
77 |
| - chmod -R +x /docker-entrypoint.d/* |
| 102 | +ENTRYPOINT ["/docker-entrypoint.sh"] |
0 commit comments