| 
 | 1 | +FROM quay.io/fedora/s2i-core:35  | 
 | 2 | + | 
 | 3 | +# PostgreSQL image for OpenShift.  | 
 | 4 | +# Volumes:  | 
 | 5 | +# * /var/lib/psql/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 NAME=postgresql \  | 
 | 14 | + VERSION=0 \  | 
 | 15 | + ARCH=x86_64 \  | 
 | 16 | + \  | 
 | 17 | + POSTGRESQL_VERSION=11 \  | 
 | 18 | + POSTGRESQL_PREV_VERSION=10 \  | 
 | 19 | + HOME=/var/lib/pgsql \  | 
 | 20 | + PGUSER=postgres \  | 
 | 21 | + APP_DATA=/opt/app-root  | 
 | 22 | + | 
 | 23 | +ENV SUMMARY="PostgreSQL is an advanced Object-Relational database management system" \  | 
 | 24 | + DESCRIPTION="PostgreSQL is an advanced Object-Relational database management system (DBMS). \  | 
 | 25 | +The image contains the client and server programs that you'll need to \  | 
 | 26 | +create, run, maintain and access a PostgreSQL DBMS server."  | 
 | 27 | + | 
 | 28 | +LABEL summary="$SUMMARY" \  | 
 | 29 | + description="$DESCRIPTION" \  | 
 | 30 | + io.k8s.description="$DESCRIPTION" \  | 
 | 31 | + io.k8s.display-name="PostgreSQL 11" \  | 
 | 32 | + io.openshift.expose-services="5432:postgresql" \  | 
 | 33 | + io.openshift.tags="database,postgresql,postgresql11" \  | 
 | 34 | + com.redhat.component="$NAME" \  | 
 | 35 | + maintainer="SoftwareCollections.org <sclorg@redhat.com>" \  | 
 | 36 | + name="fedora/$NAME-11" \  | 
 | 37 | + version="0" \  | 
 | 38 | + usage="docker run -d --name postgresql_database -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=pass -e POSTGRESQL_DATABASE=db -p 5432:5432 quay.io/fedora/$NAME-11"  | 
 | 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 bind-utils postgresql-server postgresql-contrib nss_wrapper " && \  | 
 | 48 | + INSTALL_PKGS+="findutils xz" && \  | 
 | 49 | + dnf -y module enable postgresql:11 && \  | 
 | 50 | + dnf -y --setopt=tsflags=nodocs install $INSTALL_PKGS && \  | 
 | 51 | + rpm -V $INSTALL_PKGS && \  | 
 | 52 | + dnf clean all && \  | 
 | 53 | + test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \  | 
 | 54 | + mkdir -p /var/lib/pgsql/data && \  | 
 | 55 | + /usr/libexec/fix-permissions /var/lib/pgsql /var/run/postgresql  | 
 | 56 | + | 
 | 57 | +# Get prefix path and path to scripts rather than hard-code them in scripts  | 
 | 58 | +ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql  | 
 | 59 | + | 
 | 60 | +COPY root /  | 
 | 61 | +COPY ./s2i/bin/ $STI_SCRIPTS_PATH  | 
 | 62 | + | 
 | 63 | +VOLUME ["/var/lib/pgsql/data"]  | 
 | 64 | + | 
 | 65 | +# S2I permission fixes  | 
 | 66 | +# --------------------  | 
 | 67 | +# 1. unless specified otherwise (or - equivalently - we are in OpenShift), s2i  | 
 | 68 | +# build process would be executed as 'uid=26(postgres) gid=26(postgres)'.  | 
 | 69 | +# Such process wouldn't be able to execute the default 'assemble' script  | 
 | 70 | +# correctly (it transitively executes 'fix-permissions' script). So let's  | 
 | 71 | +# add the 'postgres' user into 'root' group here  | 
 | 72 | +#  | 
 | 73 | +# 2. we call fix-permissions on $APP_DATA here directly (UID=0 during build  | 
 | 74 | +# anyways) to assure that s2i process is actually able to _read_ the  | 
 | 75 | +# user-specified scripting.  | 
 | 76 | +RUN usermod -a -G root postgres && \  | 
 | 77 | + /usr/libexec/fix-permissions --read-only "$APP_DATA"  | 
 | 78 | + | 
 | 79 | +USER 26  | 
 | 80 | + | 
 | 81 | +ENTRYPOINT ["container-entrypoint"]  | 
 | 82 | +CMD ["run-postgresql"]  | 
0 commit comments