@@ -18,7 +18,11 @@ ARG ARCH
1818
1919# Enable Beta-Repo
2020RUN ${PACKAGER} config-manager --set-enabled pgdg${PGVERSION}-updates-testing \
21- && ${PACKAGER} config-manager --set-enabled pgdg${PGVERSION}-source-updates-testing;
21+ && ${PACKAGER} config-manager --set-enabled pgdg${PGVERSION}-updates-testing-source;
22+
23+ # Spilo-specific
24+ ENV PAM_OAUTH2=v1.0.1 \
25+ PG_PERMISSIONS=REL_1_3
2226
2327# Get some Standard-Stuff
2428RUN ${PACKAGER} -y update && ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 \
@@ -33,12 +37,12 @@ RUN ${PACKAGER} -y update && ${PACKAGER} -y install --nodocs --noplugins --setop
3337 python3-pip \
3438 python3-psycopg2 \
3539 git \
36- clang \
3740 patchutils \
3841 binutils \
3942 make \
4043 cmake \
4144 gcc \
45+ clang \
4246 pam-devel \
4347 wget \
4448 mlocate \
@@ -53,6 +57,8 @@ RUN ${PACKAGER} -y update && ${PACKAGER} -y install --nodocs --noplugins --setop
5357 dumb-init \
5458 libicu \
5559 pgbackrest-${PGBACKREST_VERSION} \
60+ cronie \
61+ libcurl-devel \
5662 && ${PACKAGER} -y clean all;
5763
5864# install etcdctl
@@ -61,12 +67,27 @@ RUN curl -L https://github.com/coreos/etcd/releases/download/v${ETCD_VERSION}/et
6167ENV PATHBACKUP = $PATH
6268
6369RUN wget https://smarden.org/runit/runit-2.1.2.tar.gz -P /package/
64-
65- RUN pip3 install 'PyYAML<6.0' setuptools pystache loader kazoo meld3 boto python-etcd psutil requests cdiff ydiff --upgrade \
66- && pip3 install patroni[kubernetes$EXTRAS]==$PATRONI_VERSION --upgrade \
70+ COPY cron_unprivileged.c /package/
71+
72+ RUN pip3 install 'PyYAML<6.0' setuptools pystache loader kazoo meld3 boto python-etcd psutil requests cdiff ydiff==1.4.2 --upgrade \
73+ && if [[ $PATRONI_VERSION == "multisite-" * ]]; then \
74+ git clone -b $PATRONI_VERSION https://github.com/cybertec-postgresql/patroni; \
75+ pip3 install ./patroni[kubernetes,etcd,etcd3]; \
76+ else \
77+ pip3 install patroni[kubernetes$EXTRAS]==$PATRONI_VERSION --upgrade; \
78+ fi \
6779 && mkdir /usr/lib/postgresql \
80+ # Install pam_oauth2.so
81+ && git clone -b $PAM_OAUTH2 --recurse-submodules https://github.com/zalando-pg/pam-oauth2.git && make -C pam-oauth2 install \
82+ && git clone -b $PG_PERMISSIONS https://github.com/cybertec-postgresql/pg_permissions.git \
83+ && git clone https://github.com/dimitri/pgextwlist.git \
84+ && git clone https://github.com/crunchydata/pgnodemx \
85+ \
6886 && ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 postgresql${PGVERSION} libevent-devel brotli-devel libbrotli \
6987 && ${PACKAGER} -y clean all \
88+ \
89+ # forbid creation of a main cluster when package is installed
90+ # && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
7091\
7192# Install PostgreSQL
7293 && for version in $PG_SUPPORTED_VERSIONS; do \
@@ -75,18 +96,18 @@ RUN pip3 install 'PyYAML<6.0' setuptools pystache loader kazoo meld3 boto python
7596 # Install PostgreSQL binaries, contrib, plproxy and multiple pl's
7697 && ${PACKAGER} -y install -y postgresql${version}-contrib \
7798 postgresql${version}-devel \
78- \
7999 # Modify for using origial-spilo scripts
80100 && ln -s /usr/pgsql-${version} /usr/lib/postgresql/${version} \
81- && export PATH=$PATHBACKUP:/usr/pgsql-${version}/bin; \
101+ && export PATH=$PATHBACKUP:/usr/pgsql-${version}/bin; \
82102 done \
83103 && ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 glibc-static \
84104 && ${PACKAGER} -y clean all;
105+ RUN gcc -s -shared -fPIC -o /usr/local/lib/cron_unprivileged.so /package/cron_unprivileged.c
85106
86107 RUN cd /package && tar -xvzf runit-2.1.2.tar.gz && rm runit-2.1.2.tar.gz \
87108 && cd admin/runit-2.1.2 && package/install \
88109 && ln -s /usr/local/bin/runsvdir /usr/bin/runsvdir \
89- && rm -rf /pg_permissions* /pgextwlist /pg_stat_kcache /pgnodemx /timescaledb /set_user /pam-oauth2 \
110+ && rm -rf /pg_permissions /pgextwlist /pg_stat_kcache /pgnodemx /timescaledb /pam-oauth2 \
90111 && rm /etc/pgbackrest.conf && rm -rf /var/spool/pgbackrest \
91112 && ${PACKAGER} -y remove $(rpm -qa "*devel*" ) python3-pip python3-wheel python3-dev python3-setuptools git patchutils flatpak glibc-static gcc glibc-devel \
92113 && ${PACKAGER} -y autoremove \
@@ -131,6 +152,7 @@ RUN rm -rf /etc/service && mkdir /home/postgres/pgdata && chown -R postgres:post
131152 chmod 755 $d/* \
132153 && ln -s /run/supervise/$(basename $d) $d/supervise; \
133154 done \
155+ && chmod +r /etc/motd \
134156 && ln -snf $RW_DIR/service /etc/service \
135157 # && ln -s $RW_DIR/pam.d-postgresql /etc/pam.d/postgresql \
136158 && ln -s $RW_DIR/postgres.yml $PGHOME/postgres.yml \
@@ -149,7 +171,7 @@ RUN rm -rf /etc/service && mkdir /home/postgres/pgdata && chown -R postgres:post
149171 do echo "export $e" >> /etc/bash.bashrc; \
150172 done \
151173 && ln -s /etc/skel/.bashrc $PGHOME/.bashrc \
152- && echo "source /etc/motd" >> /root /.bashrc \
174+ && echo "source /etc/motd" >> /home/postgres /.bashrc \
153175 # Allow users in the root group to access the following files and dirs
154176 && if [ "$COMPRESS" != "true" ]; then \
155177 chmod 664 /etc/passwd \
@@ -165,6 +187,6 @@ COPY launcher/postgres/launch.sh /
165187
166188ENTRYPOINT ["/scripts/nss_wrapper/nss_wrapper.sh" ]
167189
168- USER 26
190+ USER postgres
169191
170- CMD ["/bin/sh" , "/launch.sh" , "init" ]
192+ CMD ["/bin/sh" , "/launch.sh" , "init" ]
0 commit comments