Skip to content

Commit 4d46814

Browse files
committed
update Dockerfile.rhel11
1 parent 2050801 commit 4d46814

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

1.26-minimal/Dockerfile.rhel11

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
FROM ubi10-minimal:latest
2+
3+
EXPOSE 8080
4+
EXPOSE 8443
5+
6+
ENV NAME=nginx \
7+
NGINX_VERSION=1.26 \
8+
NGINX_SHORT_VER=126 \
9+
VERSION=0
10+
11+
ENV SUMMARY="Platform for running nginx $NGINX_VERSION or building nginx-based application" \
12+
DESCRIPTION="Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP \
13+
protocols, with a strong focus on high concurrency, performance and low memory usage. The container \
14+
image provides a containerized packaging of the nginx $NGINX_VERSION daemon. The image can be used \
15+
as a base image for other applications based on nginx $NGINX_VERSION web server. \
16+
Nginx server image can be extended using source-to-image tool."
17+
18+
LABEL summary="${SUMMARY}" \
19+
description="${DESCRIPTION}" \
20+
io.k8s.description="${DESCRIPTION}" \
21+
io.k8s.display-name="Nginx ${NGINX_VERSION}" \
22+
io.openshift.expose-services="8080:http" \
23+
io.openshift.expose-services="8443:https" \
24+
io.openshift.tags="builder,${NAME},${NAME}-${NGINX_SHORT_VER}" \
25+
com.redhat.component="${NAME}-${NGINX_SHORT_VER}-container" \
26+
name="rhel11/${NAME}-${NGINX_SHORT_VER}-minimal" \
27+
version="1" \
28+
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
29+
maintainer="SoftwareCollections.org <sclorg@redhat.com>" \
30+
help="For more information visit https://github.com/sclorg/${NAME}-container" \
31+
usage="podman run -d --name nginx -p 8080:8080 rhel11/${NAME}-${NGINX_SHORT_VER}-minimal"
32+
33+
# Install nginx and required packages using microdnf
34+
RUN INSTALL_PKGS="nginx nss_wrapper-libs gettext hostname findutils tar" && \
35+
microdnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \
36+
nginx -v 2>&1 | grep -qe "$NGINX_VERSION\." && echo "Found VERSION $NGINX_VERSION" && \
37+
microdnf -y clean all --enablerepo='*'
38+
39+
# These variables are normally provided by s2i-core, but we're using minimal base
40+
ENV HOME=/opt/app-root/src \
41+
STI_SCRIPTS_PATH=/usr/libexec/s2i \
42+
APP_ROOT=/opt/app-root
43+
44+
ENV NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \
45+
NGINX_CONF_PATH=/etc/nginx/nginx.conf \
46+
NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \
47+
NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \
48+
NGINX_APP_ROOT=${APP_ROOT} \
49+
NGINX_LOG_PATH=/var/log/nginx
50+
51+
COPY root /
52+
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
53+
54+
# Changing ownership and user rights to support following use-cases:
55+
# 1) running container on OpenShift, whose default security model
56+
# is to run the container under random UID, but GID=0
57+
# 2) for working root-less container with UID=1001, which does not have
58+
# to have GID=0
59+
# 3) for default use-case, that is running container directly on operating system,
60+
# with default UID and GID (1001:0)
61+
# Supported combinations of UID:GID are thus following:
62+
# UID=1001 && GID=0
63+
# UID=<any>&& GID=0
64+
# UID=1001 && GID=<any>
65+
RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf.sed ${NGINX_CONF_PATH} && \
66+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \
67+
mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \
68+
mkdir -p ${NGINX_APP_ROOT}/src/nginx-start/ && \
69+
mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
70+
mkdir -p ${NGINX_LOG_PATH} && \
71+
chown -R 1001:0 ${NGINX_CONF_PATH} && \
72+
chown -R 1001:0 ${NGINX_APP_ROOT}/etc && \
73+
chown -R 1001:0 ${NGINX_APP_ROOT}/src/nginx-start/ && \
74+
chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
75+
chown -R 1001:0 /var/lib/nginx /var/log/nginx /run && \
76+
chmod ug+rw ${NGINX_CONF_PATH} && \
77+
chmod -R ug+rwX ${NGINX_APP_ROOT}/etc && \
78+
chmod -R ug+rwX ${NGINX_APP_ROOT}/src/nginx-start/ && \
79+
chmod -R ug+rwX ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \
80+
chmod -R ug+rwX /var/lib/nginx /var/log/nginx /run
81+
82+
USER 1001
83+
84+
STOPSIGNAL SIGQUIT
85+
86+
# Not using VOLUME statement since it's not working in OpenShift Online:
87+
# https://github.com/sclorg/httpd-container/issues/30
88+
# VOLUME ["/usr/share/nginx/html"]
89+
# VOLUME ["/var/log/nginx/"]
90+
91+
CMD $STI_SCRIPTS_PATH/usage

0 commit comments

Comments
 (0)