|
| 1 | +FROM ubi8/s2i-core:rhel8.1 |
| 2 | + |
| 3 | +# RHSCL rh-nginx114 image. |
| 4 | + |
| 5 | +EXPOSE 8080 |
| 6 | +EXPOSE 8443 |
| 7 | + |
| 8 | +ENV NAME=nginx \ |
| 9 | + NGINX_VERSION=1.14 \ |
| 10 | + NGINX_SHORT_VER=114 \ |
| 11 | + VERSION=0 |
| 12 | + |
| 13 | +ENV SUMMARY="Platform for running nginx $NGINX_VERSION or building nginx-based application" \ |
| 14 | + DESCRIPTION="Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and IMAP \ |
| 15 | +protocols, with a strong focus on high concurrency, performance and low memory usage. The container \ |
| 16 | +image provides a containerized packaging of the nginx $NGINX_VERSION daemon. The image can be used \ |
| 17 | +as a base image for other applications based on nginx $NGINX_VERSION web server. \ |
| 18 | +Nginx server image can be extended using source-to-image tool." |
| 19 | + |
| 20 | +LABEL summary="${SUMMARY}" \ |
| 21 | + description="${DESCRIPTION}" \ |
| 22 | + io.k8s.description="${DESCRIPTION}" \ |
| 23 | + io.k8s.display-name="Nginx ${NGINX_VERSION}" \ |
| 24 | + io.openshift.expose-services="8080:http" \ |
| 25 | + io.openshift.expose-services="8443:https" \ |
| 26 | + io.openshift.tags="builder,${NAME},${NAME}-${NGINX_SHORT_VER}" \ |
| 27 | + com.redhat.component="${NAME}-${NGINX_SHORT_VER}-container" \ |
| 28 | + name="rhel8/${NAME}-${NGINX_SHORT_VER}" \ |
| 29 | + version="1" \ |
| 30 | + maintainer="SoftwareCollections.org < [email protected]>" \ |
| 31 | + help="For more information visit https://github.com/sclorg/${NAME}-container" \ |
| 32 | + usage="s2i build <SOURCE-REPOSITORY> rhel8/${NAME}-${NGINX_SHORT_VER}:latest <APP-NAME>" |
| 33 | + |
| 34 | +ENV NGINX_CONFIGURATION_PATH=${APP_ROOT}/etc/nginx.d \ |
| 35 | + NGINX_CONF_PATH=/etc/nginx/nginx.conf \ |
| 36 | + NGINX_DEFAULT_CONF_PATH=${APP_ROOT}/etc/nginx.default.d \ |
| 37 | + NGINX_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/nginx \ |
| 38 | + NGINX_APP_ROOT=${APP_ROOT} \ |
| 39 | + NGINX_LOG_PATH=/var/log/nginx |
| 40 | + |
| 41 | +RUN yum -y module enable nginx:$NGINX_VERSION && \ |
| 42 | + INSTALL_PKGS="nss_wrapper bind-utils gettext hostname nginx" && \ |
| 43 | + yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \ |
| 44 | + rpm -V $INSTALL_PKGS && \ |
| 45 | + yum clean all |
| 46 | + |
| 47 | +# Copy the S2I scripts from the specific language image to $STI_SCRIPTS_PATH |
| 48 | +COPY ./s2i/bin/ $STI_SCRIPTS_PATH |
| 49 | + |
| 50 | +# Copy extra files to the image. |
| 51 | +COPY ./root/ / |
| 52 | + |
| 53 | +# In order to drop the root user, we have to make some directories world |
| 54 | +# writeable as OpenShift default security model is to run the container under |
| 55 | +# random UID. |
| 56 | +RUN sed -i -f ${NGINX_APP_ROOT}/nginxconf-fed.sed ${NGINX_CONF_PATH} && \ |
| 57 | + chmod a+rwx ${NGINX_CONF_PATH} && \ |
| 58 | + mkdir -p ${NGINX_APP_ROOT}/etc/nginx.d/ && \ |
| 59 | + mkdir -p ${NGINX_APP_ROOT}/etc/nginx.default.d/ && \ |
| 60 | + mkdir -p ${NGINX_APP_ROOT}/src/nginx-start/ && \ |
| 61 | + mkdir -p ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \ |
| 62 | + mkdir -p ${NGINX_LOG_PATH} && \ |
| 63 | + chmod -R a+rwx ${NGINX_APP_ROOT}/etc && \ |
| 64 | + chmod -R a+rwx /var/lib/nginx && \ |
| 65 | + chmod -R a+rwx ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \ |
| 66 | + chown -R 1001:0 ${NGINX_APP_ROOT} && \ |
| 67 | + chown -R 1001:0 /var/lib/nginx && \ |
| 68 | + chown -R 1001:0 ${NGINX_CONTAINER_SCRIPTS_PATH}/nginx-start && \ |
| 69 | + # FIXME: Not sure if this is safe to do, just a hack to make the image work |
| 70 | + chmod -R a+rwx /var/run && \ |
| 71 | + chown -R 1001:0 /var/run && \ |
| 72 | + rpm-file-permissions |
| 73 | + |
| 74 | +USER 1001 |
| 75 | + |
| 76 | +# Not using VOLUME statement since it's not working in OpenShift Online: |
| 77 | +# https://github.com/sclorg/httpd-container/issues/30 |
| 78 | +# VOLUME ["/usr/share/nginx/html"] |
| 79 | +# VOLUME ["/var/log/nginx/"] |
| 80 | + |
| 81 | +CMD $STI_SCRIPTS_PATH/usage |
0 commit comments