Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
58d9674
Add initial Dockerfile to build NGINX OSS images based on ubi9-minimal
shaun-nx Sep 22, 2025
20d131e
Update repo files and use red hat registered ubi-minimal
shaun-nx Sep 22, 2025
3022205
Merge branch 'main' into feat/ubi-base-image
shaun-nx Sep 22, 2025
f154680
Get required UBI packages for NGINX and install agent
shaun-nx Sep 23, 2025
42c4cec
Merge branch 'main' into feat/ubi-base-image
shaun-nx Sep 23, 2025
b880fc7
Update entrypoint to find NGINX master process. Ensure `/tmp` is writ…
shaun-nx Sep 24, 2025
c46e928
Merge branch 'main' into feat/ubi-base-image
shaun-nx Sep 24, 2025
caaf91a
Build control plane from UBI base image. Move current Alpine dockerfi…
shaun-nx Sep 24, 2025
25cee52
Add Dockerfile to build NGINX Plus image based on ubi9-minimal
shaun-nx Sep 24, 2025
fd1498c
Fix eof errors
shaun-nx Sep 24, 2025
2e9bac0
Merge branch 'feat/openshift-support' into feat/ubi-base-image
shaun-nx Sep 24, 2025
85d8358
Move alpine base Dockerfiles back to build dir
shaun-nx Sep 25, 2025
0f03b47
Merge branch 'feat/openshift-support' into feat/ubi-base-image
shaun-nx Sep 25, 2025
d28416a
Fix merge conflict
shaun-nx Sep 25, 2025
523ebd1
Update labels
shaun-nx Sep 25, 2025
31750dd
Update lables for plus builds
shaun-nx Sep 25, 2025
7146752
Update lables to distinguish between OSS and Plus
shaun-nx Sep 25, 2025
e776ae1
Make NGINX Plus version configurable
shaun-nx Sep 25, 2025
c5e49a3
Update build/ubi/Dockerfile.nginx
shaun-nx Sep 25, 2025
bc7c10f
Update lables and remove BASE_IMAGE
shaun-nx Sep 25, 2025
cbcd7ca
Remove local reference to crt and key files
shaun-nx Sep 25, 2025
048c38c
Merge branch 'feat/openshift-support' into feat/ubi-base-image
shaun-nx Sep 26, 2025
d9155b2
Set permissions on required directories. Update lables
shaun-nx Sep 26, 2025
168e2b0
Update Makefile
shaun-nx Sep 26, 2025
00dbbc6
Ensure subscription manage and shadowutils are removed
shaun-nx Sep 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ NJS_DIR = internal/controller/nginx/modules/src
KIND_CONFIG_FILE = $(SELF_DIR)config/cluster/kind-cluster.yaml
NGINX_DOCKER_BUILD_PLUS_ARGS = --secret id=nginx-repo.crt,src=$(SELF_DIR)nginx-repo.crt --secret id=nginx-repo.key,src=$(SELF_DIR)nginx-repo.key
BUILD_AGENT = local
BASE_IMAGE ?= nginx:1.29.1-alpine-otel

PROD_TELEMETRY_ENDPOINT = oss.edge.df.f5.com:443
# the telemetry related variables below are also configured in goreleaser.yml
Expand Down Expand Up @@ -43,6 +44,7 @@ HELM_SCHEMA_VERSION = 0.18.1
PREFIX ?= nginx-gateway-fabric## The name of the NGF image. For example, nginx-gateway-fabric
NGINX_PREFIX ?= $(PREFIX)/nginx## The name of the nginx image. For example: nginx-gateway-fabric/nginx
NGINX_PLUS_PREFIX ?= $(PREFIX)/nginx-plus## The name of the nginx plus image. For example: nginx-gateway-fabric/nginx-plus
BUILD_OS ?= alpine## The OS of the nginx image. Possible values: alpine and ubi
TAG ?= $(VERSION:v%=%)## The tag of the image. For example, 1.1.0
TARGET ?= local## The target of the build. Possible values: local and container
OUT_DIR ?= build/out## The folder where the binary will be stored
Expand All @@ -52,7 +54,7 @@ PLUS_ENABLED ?= false
PLUS_LICENSE_FILE ?= $(SELF_DIR)license.jwt
PLUS_USAGE_ENDPOINT ?=## The N+ usage endpoint. For development, please set to the N1 staging endpoint.

override NGINX_DOCKER_BUILD_OPTIONS += --build-arg NJS_DIR=$(NJS_DIR) --build-arg NGINX_CONF_DIR=$(NGINX_CONF_DIR) --build-arg BUILD_AGENT=$(BUILD_AGENT)
override NGINX_DOCKER_BUILD_OPTIONS += --build-arg NJS_DIR=$(NJS_DIR) --build-arg NGINX_CONF_DIR=$(NGINX_CONF_DIR) --build-arg BUILD_AGENT=$(BUILD_AGENT) --build-arg BASE_IMAGE=$(BASE_IMAGE)

.DEFAULT_GOAL := help

Expand Down Expand Up @@ -90,7 +92,7 @@ build-prod-nginx-image: build-nginx-image ## Build the custom nginx image for pr

.PHONY: build-nginx-image
build-nginx-image: check-for-docker ## Build the custom nginx image
docker build --platform linux/$(GOARCH) $(strip $(NGINX_DOCKER_BUILD_OPTIONS)) -f $(SELF_DIR)build/Dockerfile.nginx -t $(strip $(NGINX_PREFIX)):$(strip $(TAG)) $(strip $(SELF_DIR))
docker build --platform linux/$(GOARCH) $(strip $(NGINX_DOCKER_BUILD_OPTIONS)) -f $(SELF_DIR)build/$(BUILD_OS)/Dockerfile.nginx -t $(strip $(NGINX_PREFIX)):$(strip $(TAG)) $(strip $(SELF_DIR))

.PHONY: build-prod-nginx-plus-image
build-prod-nginx-plus-image: build-nginx-plus-image ## Build the custom nginx plus image for production
Expand Down
48 changes: 48 additions & 0 deletions build/ubi/Dockerfile.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# syntax=docker/dockerfile:1.18
FROM scratch AS nginx-files

# the following links can be replaced with local files if needed, i.e. ADD --chown=101:1001 <local_file> <container_file>
ADD --link --chown=101:1001 https://nginx.org/keys/nginx_signing.key nginx_signing.key
ADD --link --chown=101:1001 build/ubi/repos/nginx.repo nginx.repo
ADD --link --chown=101:1001 build/ubi/repos/agent.repo agent.repo

FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
# FROM ghcr.io/nginx/dependencies/nginx-ubi:ubi9

# renovate: datasource=github-tags depName=nginx/agent
ARG NGINX_AGENT_VERSION=v3.3.1
ARG NJS_DIR
ARG NGINX_CONF_DIR
ARG BUILD_AGENT

# c-ares is required by for nginx-module-otel. It is not available in ubi9-minimal by default
RUN --mount=type=bind,from=nginx-files,src=nginx.repo,target=/etc/yum.repos.d/nginx.repo \
--mount=type=bind,from=nginx-files,src=agent.repo,target=/etc/yum.repos.d/agent.repo \
--mount=type=bind,from=nginx-files,src=nginx_signing.key,target=/tmp/nginx_signing.key \
rpm --import /tmp/nginx_signing.key \
&& microdnf update -y \
&& microdnf --nodocs install -y shadow-utils subscription-manager \
# microdnf --enablerepo=appstream install -y c-ares \
&& microdnf --nodocs install -y nginx \
&& microdnf --nodocs install -y nginx-module-njs nginx-module-image-filter nginx-module-xslt \
&& microdnf --nodocs install -y nginx-agent-${NGINX_AGENT_VERSION#v}* \
&& microdnf clean all

RUN mkdir -p /usr/lib/nginx/modules \
# forward request and error logs to docker log collector
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log

COPY build/entrypoint.sh /agent/entrypoint.sh
COPY ${NJS_DIR}/httpmatches.js /usr/lib/nginx/modules/njs/httpmatches.js
COPY ${NGINX_CONF_DIR}/nginx.conf /etc/nginx/nginx.conf
COPY ${NGINX_CONF_DIR}/grpc-error-locations.conf /etc/nginx/grpc-error-locations.conf
COPY ${NGINX_CONF_DIR}/grpc-error-pages.conf /etc/nginx/grpc-error-pages.conf

RUN chown -R 101:1001 /etc/nginx /var/cache/nginx

LABEL org.nginx.ngf.image.build.agent="${BUILD_AGENT}"

USER 101:1001

ENTRYPOINT ["/agent/entrypoint.sh"]
5 changes: 5 additions & 0 deletions build/ubi/Dockerfile.nginxplus
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# syntax=docker/dockerfile:1.18
FROM scratch AS nginx-files

# the following links can be replaced with local files if needed, i.e. ADD --chown=101:1001 <local_file> <container_file>
ADD --link --chown=101:1001 https://cs.nginx.com/static/keys/nginx_signing.rsa.pub nginx_signing.rsa.pub
6 changes: 6 additions & 0 deletions build/ubi/repos/agent.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[agent]
name=agent repo
baseurl=https://packages.nginx.org/nginx-agent/centos/9/$basearch/
gpgcheck=1
enabled=1
module_hotfixes=true
6 changes: 6 additions & 0 deletions build/ubi/repos/nginx.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[nginx]
name=nginx repo
baseurl=https://packages.nginx.org/nginx/mainline/centos/9/$basearch/
gpgcheck=1
enabled=1
module_hotfixes=true
Loading