|
| 1 | +# syntax=docker/dockerfile:1.18 |
| 2 | +FROM scratch AS nginx-files |
| 3 | + |
| 4 | +# the following links can be replaced with local files if needed, i.e. ADD --chown=101:1001 <local_file> <container_file> |
| 5 | +ADD --link --chown=101:1001 https://cs.nginx.com/static/keys/nginx_signing.rsa.pub nginx_signing.rsa.pub |
| 6 | + |
| 7 | +FROM alpine:3.22 |
| 8 | + |
| 9 | +ARG NGINX_PLUS_VERSION=R35 |
| 10 | +# renovate: datasource=github-tags depName=nginx/agent |
| 11 | +ARG NGINX_AGENT_VERSION=v3.3.1 |
| 12 | +ARG NJS_DIR |
| 13 | +ARG NGINX_CONF_DIR |
| 14 | +ARG BUILD_AGENT |
| 15 | + |
| 16 | +RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/apk/cert.pem,mode=0644 \ |
| 17 | + --mount=type=secret,id=nginx-repo.key,dst=/etc/apk/cert.key,mode=0644 \ |
| 18 | + --mount=type=bind,from=nginx-files,src=nginx_signing.rsa.pub,target=/etc/apk/keys/nginx_signing.rsa.pub \ |
| 19 | + addgroup -g 1001 -S nginx \ |
| 20 | + && adduser -S -D -H -u 101 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx \ |
| 21 | + && printf "%s\n" "https://pkgs.nginx.com/plus/${NGINX_PLUS_VERSION}/alpine/v$(grep -E -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories \ |
| 22 | + && printf "%s\n" "https://pkgs.nginx.com/nginx-agent/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories \ |
| 23 | + && apk add --no-cache nginx-plus nginx-plus-module-njs nginx-plus-module-otel nginx-agent=${NGINX_AGENT_VERSION#v} |
| 24 | + |
| 25 | +RUN apk add --no-cache bash \ |
| 26 | + && mkdir -p /usr/lib/nginx/modules \ |
| 27 | + # forward request and error logs to docker log collector |
| 28 | + && ln -sf /dev/stdout /var/log/nginx/access.log \ |
| 29 | + && ln -sf /dev/stderr /var/log/nginx/error.log |
| 30 | + |
| 31 | +COPY build/entrypoint.sh /agent/entrypoint.sh |
| 32 | +COPY ${NJS_DIR}/httpmatches.js /usr/lib/nginx/modules/njs/httpmatches.js |
| 33 | +COPY ${NGINX_CONF_DIR}/nginx-plus.conf /etc/nginx/nginx.conf |
| 34 | +COPY ${NGINX_CONF_DIR}/grpc-error-locations.conf /etc/nginx/grpc-error-locations.conf |
| 35 | +COPY ${NGINX_CONF_DIR}/grpc-error-pages.conf /etc/nginx/grpc-error-pages.conf |
| 36 | + |
| 37 | +RUN chown -R 101:1001 /etc/nginx /var/cache/nginx /var/lib/nginx |
| 38 | + |
| 39 | +USER 101:1001 |
| 40 | + |
| 41 | +LABEL org.nginx.ngf.image.build.agent="${BUILD_AGENT}" |
| 42 | + |
| 43 | +ENTRYPOINT ["/agent/entrypoint.sh"] |
0 commit comments