Skip to content

Commit

Permalink
Add nginx 1.24 for rhel8 and rhel9 (#278)
Browse files Browse the repository at this point in the history
* remove .exclude-rhel8 because we have devel-repos
* Add Dockerfile.rhel9 for testing on RHEL9 host
* Add CentOS Stream 8 Dockerfile for Nginx-1.24
* Build and push CentOS Stream 8,9 Nginx-1.24 images
* Fix typo in build-and-push.yml. It is nginx-124-c{8,9}s
* Based on the issue sclorg/httpd-container#30

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
  • Loading branch information
phracek committed Feb 21, 2024
1 parent 81d03a9 commit 208cee3
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 16 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ jobs:
quayio_token: "QUAY_IMAGE_FEDORA_BUILDER_TOKEN"
tag: "fedora"
image_name: "nginx-124"
- dockerfile: "1.24/Dockerfile.c8s"
registry_namespace: "sclorg"
quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
tag: "c8s"
image_name: "nginx-124-c8s"
- dockerfile: "1.24/Dockerfile.c9s"
registry_namespace: "sclorg"
quayio_username: "QUAY_IMAGE_SCLORG_BUILDER_USERNAME"
quayio_token: "QUAY_IMAGE_SCLORG_BUILDER_TOKEN"
tag: "c9s"
image_name: "nginx-124-c9s"

steps:
- name: Build and push to quay.io registry
Expand Down
Empty file removed 1.24/.exclude-c9s
Empty file.
Empty file removed 1.24/.exclude-rhel8
Empty file.
88 changes: 88 additions & 0 deletions 1.24/Dockerfile.c8s
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
FROM quay.io/sclorg/s2i-core-c8s:c8s

EXPOSE 8080
EXPOSE 8443

ENV NAME=nginx \
NGINX_VERSION=1.24 \
NGINX_SHORT_VER=124 \
VERSION=0

ENV SUMMARY="Platform for running nginx $NGINX_VERSION or building nginx-based application" \
DESCRIPTION="Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP \
protocols, with a strong focus on high concurrency, performance and low memory usage. The container \
image provides a containerized packaging of the nginx $NGINX_VERSION daemon. The image can be used \
as a base image for other applications based on nginx $NGINX_VERSION web server. \
Nginx server image can be extended using source-to-image tool."

LABEL summary="${SUMMARY}" \
description="${DESCRIPTION}" \
io.k8s.description="${DESCRIPTION}" \
io.k8s.display-name="Nginx ${NGINX_VERSION}" \
io.openshift.expose-services="8080:http" \
io.openshift.expose-services="8443:https" \
io.openshift.tags="builder,${NAME},${NAME}-${NGINX_SHORT_VER}" \
com.redhat.component="${NAME}-${NGINX_SHORT_VER}-container" \
name="sclorg/${NAME}-${NGINX_SHORT_VER}-c8s" \
version="1" \
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
help="For more information visit https://github.com/sclorg/${NAME}-container" \
usage="s2i build <SOURCE-REPOSITORY> quay.io/sclorg/${NAME}-${NGINX_SHORT_VER}-c8s:latest <APP-NAME>"

ENV NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \
NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \
NGINX_APP_ROOT=${APP_ROOT} \
NGINX_LOG_PATH=/var/log/nginx \
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl

RUN yum -y module enable nginx:$NGINX_VERSION && \
INSTALL_PKGS="nss_wrapper bind-utils gettext hostname nginx nginx-mod-stream nginx-mod-http-perl" && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
nginx -v 2>&1 | grep -qe "nginx/$NGINX_VERSION\." && echo "Found VERSION $NGINX_VERSION" && \
yum -y clean all --enablerepo='*'

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY $NGINX_VERSION/s2i/bin/ $STI_SCRIPTS_PATH

# Copy extra files to the image.
COPY $NGINX_VERSION/root/ /

# Changing ownership and user rights to support following use-cases:
# 1) running container on OpenShift, whose default security model
# is to run the container under random UID, but GID=0
# 2) for working root-less container with UID=1001, which does not have
# to have GID=0
# 3) for default use-case, that is running container directly on operating system,
# with default UID and GID (1001:0)
# Supported combinations of UID:GID are thus following:
# UID=1001 && GID=0
# UID=<any>&& GID=0
# UID=1001 && GID=<any>
RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \
mkdir -p ${NGINX_APP_ROOT}/src/nginx-start/ && \
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
mkdir -p ${NGINX_LOG_PATH} && \
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
chown -R 1001:0 ${NGINX_CONF_PATH} && \
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
chown -R 1001:0 ${NGINX_APP_ROOT}/src/nginx-start/ && \
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
chmod ug+rw ${NGINX_CONF_PATH} && \
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
chmod -R ug+rwX ${NGINX_APP_ROOT}/src/nginx-start/ && \
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run && \
rpm-file-permissions

USER 1001

STOPSIGNAL SIGQUIT

CMD $STI_SCRIPTS_PATH/usage
7 changes: 1 addition & 6 deletions 1.24/Dockerfile.c9s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/sclorg/s2i-base-c9s:c9s
FROM quay.io/sclorg/s2i-core-c9s:c9s

EXPOSE 8080
EXPOSE 8443
Expand Down Expand Up @@ -86,9 +86,4 @@ USER 1001

STOPSIGNAL SIGQUIT

# Not using VOLUME statement since it's not working in OpenShift Online:
# https://github.com/sclorg/httpd-container/issues/30
# VOLUME ["/usr/share/nginx/html"]
# VOLUME ["/var/log/nginx/"]

CMD $STI_SCRIPTS_PATH/usage
5 changes: 0 additions & 5 deletions 1.24/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,4 @@ USER 1001

STOPSIGNAL SIGQUIT

# Not using VOLUME statement since it's not working in OpenShift Online:
# https://github.com/sclorg/httpd-container/issues/30
# VOLUME ["/usr/share/nginx/html"]
# VOLUME ["/var/log/nginx/"]

CMD $STI_SCRIPTS_PATH/usage
5 changes: 0 additions & 5 deletions 1.24/Dockerfile.rhel8
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,4 @@ USER 1001

STOPSIGNAL SIGQUIT

# Not using VOLUME statement since it's not working in OpenShift Online:
# https://github.com/sclorg/httpd-container/issues/30
# VOLUME ["/usr/share/nginx/html"]
# VOLUME ["/var/log/nginx/"]

CMD $STI_SCRIPTS_PATH/usage
88 changes: 88 additions & 0 deletions 1.24/Dockerfile.rhel9
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
FROM ubi9/s2i-core:1

EXPOSE 8080
EXPOSE 8443

ENV NAME=nginx \
NGINX_VERSION=1.24 \
NGINX_SHORT_VER=124 \
VERSION=0

ENV SUMMARY="Platform for running nginx $NGINX_VERSION or building nginx-based application" \
DESCRIPTION="Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP \
protocols, with a strong focus on high concurrency, performance and low memory usage. The container \
image provides a containerized packaging of the nginx $NGINX_VERSION daemon. The image can be used \
as a base image for other applications based on nginx $NGINX_VERSION web server. \
Nginx server image can be extended using source-to-image tool."

LABEL summary="${SUMMARY}" \
description="${DESCRIPTION}" \
io.k8s.description="${DESCRIPTION}" \
io.k8s.display-name="Nginx ${NGINX_VERSION}" \
io.openshift.expose-services="8080:http" \
io.openshift.expose-services="8443:https" \
io.openshift.tags="builder,${NAME},${NAME}-${NGINX_SHORT_VER}" \
com.redhat.component="${NAME}-${NGINX_SHORT_VER}-container" \
name="ubi9/${NAME}-${NGINX_SHORT_VER}" \
version="1" \
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \
maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
help="For more information visit https://github.com/sclorg/${NAME}-container" \
usage="s2i build <SOURCE-REPOSITORY> ubi9/${NAME}-${NGINX_SHORT_VER}:latest <APP-NAME>"

ENV NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \
NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \
NGINX_APP_ROOT=${APP_ROOT} \
NGINX_LOG_PATH=/var/log/nginx \
NGINX_PERL_MODULE_PATH=${APP_ROOT}/etc/perl

RUN yum -y module enable nginx:$NGINX_VERSION && \
INSTALL_PKGS="nss_wrapper bind-utils gettext hostname nginx nginx-mod-stream nginx-mod-http-perl" && \
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
rpm -V $INSTALL_PKGS && \
nginx -v 2>&1 | grep -qe "nginx/$NGINX_VERSION\." && echo "Found VERSION $NGINX_VERSION" && \
yum -y clean all --enablerepo='*'

# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH
COPY $NGINX_VERSION/s2i/bin/ $STI_SCRIPTS_PATH

# Copy extra files to the image.
COPY $NGINX_VERSION/root/ /

# Changing ownership and user rights to support following use-cases:
# 1) running container on OpenShift, whose default security model
# is to run the container under random UID, but GID=0
# 2) for working root-less container with UID=1001, which does not have
# to have GID=0
# 3) for default use-case, that is running container directly on operating system,
# with default UID and GID (1001:0)
# Supported combinations of UID:GID are thus following:
# UID=1001 && GID=0
# UID=<any>&& GID=0
# UID=1001 && GID=<any>
RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \
mkdir -p ${NGINX_APP_ROOT}/src/nginx-start/ && \
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
mkdir -p ${NGINX_LOG_PATH} && \
mkdir -p ${NGINX_PERL_MODULE_PATH} && \
chown -R 1001:0 ${NGINX_CONF_PATH} && \
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
chown -R 1001:0 ${NGINX_APP_ROOT}/src/nginx-start/ && \
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
chmod ug+rw ${NGINX_CONF_PATH} && \
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
chmod -R ug+rwX ${NGINX_APP_ROOT}/src/nginx-start/ && \
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run && \
rpm-file-permissions

USER 1001

STOPSIGNAL SIGQUIT

CMD $STI_SCRIPTS_PATH/usage

0 comments on commit 208cee3

Please sign in to comment.