|
1 | 1 | FROM quay.io/centos/centos:stream10 |
2 | 2 |
|
3 | | -# PostgreSQL image for OpenShift. |
4 | | -# Volumes: |
5 | | -# * /var/lib/pgsql/data - Database cluster for PostgreSQL |
6 | | -# Environment: |
7 | | -# * $POSTGRESQL_USER - Database user name |
8 | | -# * $POSTGRESQL_PASSWORD - User's password |
9 | | -# * $POSTGRESQL_DATABASE - Name of the database to create |
10 | | -# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres' |
11 | | -# PostgreSQL administrative account |
| 3 | +EXPOSE 8080 |
| 4 | +EXPOSE 8443 |
12 | 5 |
|
13 | | -ENV POSTGRESQL_VERSION=18 \ |
14 | | - POSTGRESQL_PREV_VERSION=16 \ |
15 | | - HOME=/var/lib/pgsql \ |
16 | | - PGUSER=postgres \ |
17 | | - # Path to be used in other layers to place s2i scripts into |
18 | | - STI_SCRIPTS_PATH=/usr/libexec/s2i \ |
19 | | - HOME=/opt/app-root/src \ |
20 | | - APP_DATA=/opt/app-root |
| 6 | +ENV NAME=nginx \ |
| 7 | + NGINX_VERSION=1.26 \ |
| 8 | + NGINX_SHORT_VER=126 \ |
| 9 | + VERSION=0 |
21 | 10 |
|
22 | | -ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \ |
23 | | - DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \ |
24 | | -The image contains the client and server programs that you'll need to \ |
25 | | -create, run, maintain and access a PostgreSQL DBMS server." |
| 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." |
26 | 17 |
|
27 | | -LABEL summary="$SUMMARY" \ |
28 | | - description="$DESCRIPTION" \ |
29 | | - io.k8s.description="$DESCRIPTION" \ |
30 | | - io.k8s.display-name="PostgreSQL 18" \ |
31 | | - io.openshift.expose-services="5432:postgresql" \ |
32 | | - io.openshift.tags="database,postgresql,postgresql18,postgresql-18" \ |
33 | | - io.openshift.s2i.assemble-user="26" \ |
34 | | - name="sclorg/postgresql-18-minimal-c11s" \ |
35 | | - com.redhat.component="postgresql-18-container" \ |
| 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="sclorg/${NAME}-${NGINX_SHORT_VER}-minimal-c11s" \ |
36 | 27 | version="1" \ |
37 | | - usage="podman run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 sclorg/postgresql-18-minimal-c11s" \ |
38 | | - maintainer="SoftwareCollections.org <sclorg@redhat.com>" |
39 | | - |
40 | | -EXPOSE 5432 |
| 28 | + com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#UBI" \ |
| 29 | + maintainer="SoftwareCollections.org <sclorg@redhat.com>" \ |
| 30 | + help="For more information visit https://github.com/sclorg/${NAME}-container" \ |
| 31 | + usage="s2i build <SOURCE-REPOSITORY> quay.io/sclorg/${NAME}-${NGINX_SHORT_VER}-minimal-c11s:latest <APP-NAME>" |
41 | 32 |
|
42 | | -COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions |
| 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='*' |
43 | 38 |
|
44 | | -# This image must forever use UID 26 for postgres user so our volumes are |
45 | | -# safe in the future. This should *never* change, the last test is there |
46 | | -# to make sure of that. |
47 | | -RUN INSTALL_PKGS="rsync tar gettext-envsubst nss_wrapper-libs glibc-locale-source xz" && \ |
48 | | - PSQL_PKGS="postgresql18-server postgresql18-contrib postgresql18-upgrade" && \ |
49 | | - INSTALL_PKGS="$INSTALL_PKGS postgresql18-pgaudit" && \ |
50 | | - PSQL_PKGS="$PSQL_PKGS postgresql18-pgvector" && \ |
51 | | - microdnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS $PSQL_PKGS && \ |
52 | | - rpm -V $INSTALL_PKGS && \ |
53 | | - postgres -V | grep -qe "$POSTGRESQL_VERSION\." && echo "Found VERSION $POSTGRESQL_VERSION" && \ |
54 | | - microdnf -y clean all --enablerepo='*' && \ |
55 | | - mkdir -p ${HOME}/.pki/nssdb && \ |
56 | | - chown -R 1001:0 ${HOME}/.pki && \ |
57 | | - localedef -f UTF-8 -i en_US en_US.UTF-8 && \ |
58 | | - test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \ |
59 | | - mkdir -p /var/lib/pgsql/data && \ |
60 | | - mkdir -p /run/postgresql && \ |
61 | | - /usr/libexec/fix-permissions /var/lib/pgsql /run/postgresql |
| 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 |
62 | 43 |
|
63 | | -# Get prefix path and path to scripts rather than hard-code them in scripts |
64 | | -ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql |
| 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 |
65 | 50 |
|
66 | 51 | COPY root / |
67 | 52 | COPY ./s2i/bin/ $STI_SCRIPTS_PATH |
68 | 53 |
|
69 | | -# Hard links are not supported in Testing Farm approach during sync to guest |
70 | | -# operation system. Therefore tests are failing on error |
71 | | -# /usr/libexec/s2i/run no such file or directory |
72 | | -RUN ln -s /usr/bin/run-postgresql $STI_SCRIPTS_PATH/run |
| 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 |
73 | 81 |
|
| 82 | +USER 1001 |
74 | 83 |
|
75 | | -# S2I permission fixes |
76 | | -# -------------------- |
77 | | -# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i |
78 | | -# build process would be executed as 'uid=26(postgres) gid=26(postgres)'. |
79 | | -# Such process wouldn't be able to execute the default 'assemble' script |
80 | | -# correctly (it transitively executes 'fix-permissions' script). So let's |
81 | | -# add the 'postgres' user into 'root' group here |
82 | | -# |
83 | | -# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build |
84 | | -# anyways) to assure that s2i process is actually able to _read_ the |
85 | | -# user-specified scripting. |
86 | | -RUN usermod -a -G root postgres && \ |
87 | | - /usr/libexec/fix-permissions --read-only "$APP_DATA" |
| 84 | +STOPSIGNAL SIGQUIT |
88 | 85 |
|
89 | | -USER 26 |
| 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 | 90 |
|
91 | | -ENTRYPOINT ["container-entrypoint"] |
92 | | -CMD ["run-postgresql"] |
| 91 | +CMD $STI_SCRIPTS_PATH/usage |
0 commit comments