Skip to content

Commit f154680

Browse files
committed
Get required UBI packages for NGINX and install agent
1 parent 3022205 commit f154680

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ PREFIX ?= nginx-gateway-fabric## The name of the NGF image. For example, nginx-g
4545
NGINX_PREFIX ?= $(PREFIX)/nginx## The name of the nginx image. For example: nginx-gateway-fabric/nginx
4646
NGINX_PLUS_PREFIX ?= $(PREFIX)/nginx-plus## The name of the nginx plus image. For example: nginx-gateway-fabric/nginx-plus
4747
BUILD_OS ?= alpine## The OS of the nginx image. Possible values: alpine and ubi
48+
IMAGE_PULL_POLICY ?= Never## The image pull policy for the NGF and nginx images. Possible values: Always, Never, IfNotPresent
4849
TAG ?= $(VERSION:v%=%)## The tag of the image. For example, 1.1.0
4950
TARGET ?= local## The target of the build. Possible values: local and container
5051
OUT_DIR ?= build/out## The folder where the binary will be stored
@@ -228,7 +229,7 @@ install-ngf-local-build-with-plus: check-for-plus-usage-endpoint build-images-wi
228229

229230
.PHONY: helm-install-local
230231
helm-install-local: install-gateway-crds ## Helm install NGF on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build.
231-
helm install nginx-gateway $(CHART_DIR) --set nginx.image.repository=$(NGINX_PREFIX) --create-namespace --wait --set nginxGateway.image.pullPolicy=Never --set nginx.service.type=NodePort --set nginxGateway.image.repository=$(PREFIX) --set nginxGateway.image.tag=$(TAG) --set nginx.image.tag=$(TAG) --set nginx.image.pullPolicy=Never --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL) -n nginx-gateway $(HELM_PARAMETERS)
232+
helm install nginx-gateway $(CHART_DIR) --set nginx.image.repository=$(NGINX_PREFIX) --create-namespace --wait --set nginxGateway.image.pullPolicy=$(IMAGE_PULL_POLICY) --set nginx.service.type=NodePort --set nginxGateway.image.repository=$(PREFIX) --set nginxGateway.image.tag=$(TAG) --set nginx.image.tag=$(TAG) --set nginx.image.pullPolicy=$(IMAGE_PULL_POLICY) --set nginxGateway.gwAPIExperimentalFeatures.enable=$(ENABLE_EXPERIMENTAL) -n nginx-gateway $(HELM_PARAMETERS) || helm uninstall nginx-gateway -n nginx-gateway
232233

233234
.PHONY: helm-install-local-with-plus
234235
helm-install-local-with-plus: check-for-plus-usage-endpoint install-gateway-crds ## Helm install NGF with NGINX Plus on configured kind cluster with local images. To build, load, and install with helm run make install-ngf-local-build-with-plus.

build/entrypoint.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ nginx_pid=$!
4141

4242
SECONDS=0
4343

44-
while ! ps -ef | grep "nginx: master process" | grep -v grep; do
45-
if ((SECONDS > 5)); then
46-
echo "couldn't find nginx master process"
44+
while ! curl localhost:80 -s -o /dev/null; do
45+
if ((SECONDS > 10)); then
46+
echo "nginx didn't start within 10 seconds"
4747
exit 1
4848
fi
49+
sleep 200
4950
done
5051

5152
# start nginx-agent, pass args

build/ubi/Dockerfile.nginx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,61 @@ ADD --link --chown=101:1001 https://nginx.org/keys/nginx_signing.key nginx_signi
66
ADD --link --chown=101:1001 build/ubi/repos/nginx.repo nginx.repo
77
ADD --link --chown=101:1001 build/ubi/repos/agent.repo agent.repo
88

9+
FROM ghcr.io/nginx/dependencies/nginx-ubi:ubi9@sha256:01a32246761b9bbe47a6a29bcd8ca6e9b6e331b3bdfa372d8987b622276f7025 AS packages
10+
911
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
10-
# FROM ghcr.io/nginx/dependencies/nginx-ubi:ubi9
1112

1213
# renovate: datasource=github-tags depName=nginx/agent
1314
ARG NGINX_AGENT_VERSION=v3.3.1
1415
ARG NJS_DIR
1516
ARG NGINX_CONF_DIR
1617
ARG BUILD_AGENT
1718

18-
# c-ares is required by for nginx-module-otel. It is not available in ubi9-minimal by default
19+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
20+
# Prepare packages
1921
RUN --mount=type=bind,from=nginx-files,src=nginx.repo,target=/etc/yum.repos.d/nginx.repo \
2022
--mount=type=bind,from=nginx-files,src=agent.repo,target=/etc/yum.repos.d/agent.repo \
2123
--mount=type=bind,from=nginx-files,src=nginx_signing.key,target=/tmp/nginx_signing.key \
24+
--mount=type=bind,from=packages,src=/,target=/ubi-bin/ \
2225
rpm --import /tmp/nginx_signing.key \
2326
&& microdnf update -y \
2427
&& microdnf --nodocs install -y shadow-utils subscription-manager \
25-
# microdnf --enablerepo=appstream install -y c-ares \
28+
&& rpm -qa --queryformat "%{NAME}\n" | sort > pkgs-installed \
29+
&& microdnf --nodocs --setopt=install_weak_deps=0 install -y diffutils dnf \
30+
&& rpm -qa --queryformat "%{NAME}\n" | sort > pkgs-new \
31+
&& dnf install -y /ubi-bin/*.rpm \
32+
&& dnf -q repoquery --resolve --requires --recursive --whatrequires nginx --queryformat "%{NAME}" > pkgs-nginx \
33+
&& dnf --setopt=protected_packages= remove -y $(comm -13 pkgs-installed pkgs-new | comm -13 pkgs-nginx -) \
34+
&& rm pkgs-installed pkgs-new pkgs-nginx \
2635
&& microdnf --nodocs install -y nginx \
2736
&& microdnf --nodocs install -y nginx-module-njs nginx-module-image-filter nginx-module-xslt \
28-
&& microdnf --nodocs install -y nginx-agent-${NGINX_AGENT_VERSION#v}* \
29-
&& microdnf clean all
37+
# && microdnf --enablerepo=appstream install -y c-ares \
38+
&& microdnf --nodocs install -y nginx-agent-${NGINX_AGENT_VERSION#v}
39+
40+
# RUN rm /etc/yum.repos.d/nginx.repo \
41+
# && rm /etc/yum.repos.d/agent.repo \
42+
# && microdnf clean all
3043

44+
# Configure logs and directories
3145
RUN mkdir -p /usr/lib/nginx/modules \
32-
# forward request and error logs to docker log collector
46+
&& mkdir -p /usr/lib64/nginx/modules \
47+
&& mkdir -p /var/run/nginx \
3348
&& ln -sf /dev/stdout /var/log/nginx/access.log \
34-
&& ln -sf /dev/stderr /var/log/nginx/error.log
49+
&& ln -sf /dev/stderr /var/log/nginx/error.log \
50+
&& cp -r /usr/lib64/nginx/modules/ngx_* /usr/lib/nginx/modules/
51+
# && ln -sf /usr/lib64/nginx/modules/ngx_http_js_module.so /usr/lib/nginx/modules/ngx_http_js_module.so \
52+
# && ln -sf /usr/lib64/nginx/modules/ngx_stream_js_module.so /usr/lib/nginx/modules/ngx_stream_js_module.so
3553

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

42-
RUN chown -R 101:1001 /etc/nginx /var/cache/nginx
60+
RUN chown -R 101:1001 /etc/nginx /var/cache/nginx /var/run/nginx /etc/nginx-agent/nginx-agent.conf
4361

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

4664
USER 101:1001
4765

48-
ENTRYPOINT ["/agent/entrypoint.sh"]
66+
ENTRYPOINT ["/agent/entrypoint.sh"]

0 commit comments

Comments
 (0)