Skip to content

Commit 7730a46

Browse files
committed
use postgresql as a template
1 parent 00b4cb3 commit 7730a46

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

1.26-minimal/Dockerfile.c11s

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
FROM quay.io/centos/centos:stream10
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
12+
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
21+
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."
26+
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" \
36+
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
41+
42+
COPY root/usr/libexec/fix-permissions /usr/libexec/fix-permissions
43+
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
62+
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
65+
66+
COPY root /
67+
COPY ./s2i/bin/ $STI_SCRIPTS_PATH
68+
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
73+
74+
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"
88+
89+
USER 26
90+
91+
ENTRYPOINT ["container-entrypoint"]
92+
CMD ["run-postgresql"]

0 commit comments

Comments
 (0)