Skip to content

Commit 8c26788

Browse files
committed
done
1 parent ce588e8 commit 8c26788

8 files changed

Lines changed: 55 additions & 103 deletions

File tree

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ PGBACKREST_VERSION ?= 2.50
1313
POSTGIS_VERSION ?= 34
1414
PACKAGER ?= dnf
1515
BUILD ?= 1
16+
ARCH ?= amd64
1617
IMAGE_TAG ?= $(BASEOS)-$(PGVERSION_FULL)-$(BUILD)
1718
POSTGIS_IMAGE_TAG ?= $(BASEOS)-$(PGVERSION_FULL)-$(POSTGIS_VERSION)-$(BUILD)
1819

@@ -72,10 +73,11 @@ postgres-build:
7273
--build-arg PACKAGER=$(PACKAGER) \
7374
--build-arg CONTAINERSUITE=$(CONTAINERSUITE) \
7475
--build-arg BUILD=$(BUILD) \
76+
--build-arg ARCH=$(ARCH) \
7577
--build-arg PGBACKREST_VERSION=$(PGBACKREST_VERSION) \
7678
--build-arg PATRONI_VERSION=$(PATRONI_VERSION) \
7779
--build-arg OLD_PG_VERSIONS="$(OLD_PG_VERSIONS)" \
78-
--build-arg PGVERSION=$(PGVERSION)
80+
--build-arg PGVERSION=$(PGVERSION)
7981

8082
postgres: postgres-build
8183

@@ -92,7 +94,7 @@ postgres-stage-build:
9294
--build-arg PGBACKREST_VERSION=$(PGBACKREST_VERSION) \
9395
--build-arg PATRONI_VERSION=$(PATRONI_VERSION) \
9496
--build-arg OLD_PG_VERSIONS="$(OLD_PG_VERSIONS)" \
95-
--build-arg PGVERSION=$(PGVERSION)
97+
--build-arg PGVERSION=$(PGVERSION)
9698

9799
postgres-stage: postgres-stage-build
98100

@@ -110,7 +112,7 @@ postgres-gis-build:
110112
--build-arg PATRONI_VERSION=$(PATRONI_VERSION) \
111113
--build-arg OLD_PG_VERSIONS="$(OLD_PG_VERSIONS)" \
112114
--build-arg PGVERSION=$(PGVERSION) \
113-
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)
115+
--build-arg POSTGIS_VERSION=$(POSTGIS_VERSION)
114116

115117
postgres-gis: postgres-gis-build
116118

docker/pgbackrest/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ RUN if [ "$BASEOS" = "ubi8" ] ; then \
2020
tar \
2121
bzip2 \
2222
lz4 \
23-
#crunchy-backrest-${BACKREST_VER} \
23+
dumb-init \
24+
pgbackrest-${PGBACKREST_VERSION} \
2425
&& ${PACKAGER} -y clean all ; \
2526
else \
2627
${PACKAGER} -y install --nodocs \
@@ -30,8 +31,8 @@ else \
3031
bzip2 \
3132
lz4 \
3233
#postgresql${PGVERSION}-server \
34+
dumb-init \
3335
pgbackrest-${PGBACKREST_VERSION} \
34-
nano \
3536
&& ${PACKAGER} -y clean all ; \
3637
fi
3738

@@ -86,4 +87,4 @@ ENTRYPOINT ["/scripts/nss_wrapper/nss_wrapper.sh"]
8687

8788
USER 26
8889

89-
CMD ["/bin/sh", "/launch.sh", "init"]
90+
CMD ["dumb-init", "/launch.sh", "init"]

docker/postgres/Dockerfile

Lines changed: 16 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ ARG OLD_PG_VERSIONS
1313
ARG PG_SUPPORTED_VERSIONS="$PGVERSION"
1414
ARG PG_SUPPORTED_VERSIONS="$OLD_PG_VERSIONS $PGVERSION"
1515
ARG TIMESCALEDB="1.7.5 2.3.1 2.13.0"
16+
ARG ARCH
1617
# Spilo-specific
1718
ENV SET_USER=REL3_0_0 \
18-
#BG_MON_COMMIT=e22182e129ce357b5aa80090fba2aacfc42b1996 \
19-
#PG_AUTH_MON_COMMIT=52d90bbaa6d3c61195cd9532ebe036b1183808c5 \
20-
#PG_MON_COMMIT=54fbdcc3cfe7e2a626bd96dda644d9a0c6866b58 \
2119
PLPROFILER=REL4_1 \
2220
PG_PROFILE=0.3.6 \
2321
PAM_OAUTH2=v1.0.1 \
@@ -28,6 +26,7 @@ ENV SET_USER=REL3_0_0 \
2826
# Get some Standard-Stuff
2927
RUN if [ "$BASEOS" = "ubi8" ] ; then \
3028
${PACKAGER} -y update && ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 \
29+
--setopt=skip_missing_names_on_install=False \
3130
openssh-clients \
3231
openssh-server \
3332
shadow-utils \
@@ -40,15 +39,14 @@ RUN if [ "$BASEOS" = "ubi8" ] ; then \
4039
python3-psutil \
4140
python3-requests \
4241
python3-etcd \
43-
#python3-pyyaml \
42+
python3-pyyaml \
43+
python3-setuptools \
4444
git \
4545
patchutils \
4646
binutils \
4747
make \
4848
cmake \
4949
gcc \
50-
#curl \
51-
libcurl-devel \
5250
pam-devel \
5351
wget \
5452
mlocate \
@@ -58,11 +56,11 @@ RUN if [ "$BASEOS" = "ubi8" ] ; then \
5856
redhat-rpm-config \
5957
krb5-devel \
6058
busybox \
61-
dpkg \
6259
jq \
6360
rsync \
61+
dumb-init \
6462
libicu \
65-
pgbackrest-${PGBACKREST_VERSION} \
63+
pgbackrest-${PGBACKREST_VERSION} \
6664
&& ${PACKAGER} -y clean all ; \
6765
else \
6866
${PACKAGER} -y update && ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 \
@@ -78,17 +76,15 @@ else \
7876
python3-psycopg2 \
7977
python3-psutil \
8078
python3-requests \
81-
python3-etcd \
79+
#python3-etcd \
8280
python3-pyyaml \
83-
python3-etcd \
81+
python3-setuptools \
8482
git \
8583
patchutils \
8684
binutils \
8785
make \
8886
cmake \
8987
gcc \
90-
#curl \
91-
libcurl-devel \
9288
pam-devel \
9389
wget \
9490
mlocate \
@@ -98,7 +94,6 @@ else \
9894
redhat-rpm-config \
9995
krb5-devel \
10096
busybox \
101-
dpkg \
10297
jq \
10398
rsync \
10499
dumb-init \
@@ -107,71 +102,22 @@ else \
107102
&& ${PACKAGER} -y clean all ; \
108103
fi
109104

110-
# RUN ${PACKAGER} -y update && ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 \
111-
# openssh-clients \
112-
# openssh-server \
113-
# shadow-utils \
114-
# tar \
115-
# bzip2 \
116-
# lz4 \
117-
# python3 \
118-
# python3-pip \
119-
# python3-psycopg2 \
120-
# python3-psutil \
121-
# python3-requests \
122-
# python3-etcd \
123-
# #python3-pyyaml \
124-
# git \
125-
# patchutils \
126-
# binutils \
127-
# make \
128-
# cmake \
129-
# gcc \
130-
# #curl \
131-
# libcurl-devel \
132-
# pam-devel \
133-
# wget \
134-
# mlocate \
135-
# git-clang-format \
136-
# openssl-devel \
137-
# ccache \
138-
# redhat-rpm-config \
139-
# krb5-devel \
140-
# busybox \
141-
# dpkg \
142-
# jq \
143-
# rsync \
144-
# && ${PACKAGER} -y clean all;
145-
146105
# install etcdctl
147-
RUN ETCDVERSION=3.3.27 \
148-
&& curl -L https://github.com/coreos/etcd/releases/download/v${ETCDVERSION}/etcd-v${ETCDVERSION}-linux-$(dpkg --print-architecture).tar.gz \
106+
RUN ETCDVERSION=3.5.13 \
107+
&& curl -L https://github.com/coreos/etcd/releases/download/v${ETCDVERSION}/etcd-v${ETCDVERSION}-linux-${ARCH}.tar.gz \
149108
| tar xz -C /bin --strip=1 --wildcards --no-anchored --no-same-owner etcdctl etcd;
150109

151-
# Install Patroni
152-
# RUN pip3 install 'PyYAML<6.0' setuptools pystache loader dumb-init kazoo meld3 boto
153-
# #swiftclient
154-
# RUN ${PACKAGER} -y install --nodocs --noplugins --setopt=install_weak_deps=0 \
155-
# python3-etcd python3-consul \
156-
# python3-gevent python3-greenlet python3-cachetools \
157-
# python3-rsa python3-pyasn1-modules python3-cffi \
158-
# && ${PACKAGER} -y clean all;
159-
160-
# python3-kazoo python3-meld3 python3-boto python3-swiftclient
161-
162-
#RUN pip3 install patroni[kubernetes$EXTRAS]==$PATRONI_VERSION
163-
164-
#RUN mkdir /usr/lib/postgresql
165110
ENV PATHBACKUP = $PATH
166-
#ENV PATH=$PATH:/usr/pgsql-$PGVERSION/bin
167-
#RUN echo $PATH
111+
168112
# Install pam_oauth2.so
169113
#RUN #git clone -b $PAM_OAUTH2 --recurse-submodules https://github.com/zalando-pg/pam-oauth2.git \
170114
#&& make -C pam-oauth2 install \
171115
#&& curl -sL https://github.com/zalando-pg/bg_mon/archive/$BG_MON_COMMIT.tar.gz | tar xz \
172116
#&& curl -sL https://github.com/zalando-pg/pg_auth_mon/archive/$PG_AUTH_MON_COMMIT.tar.gz | tar xz \
173-
RUN pip3 install 'PyYAML<6.0' setuptools pystache loader dumb-init kazoo meld3 boto \
174-
&& pip3 install patroni[kubernetes$EXTRAS]==$PATRONI_VERSION \
117+
118+
#pip3.11 install 'PyYAML<6.0' setuptools pystache loader dumb-init kazoo meld3 boto \
119+
RUN pip3 install 'PyYAML<6.0' setuptools pystache loader dumb-init kazoo meld3 boto python-etcd --upgrade \
120+
&& pip3 install patroni[kubernetes$EXTRAS]==$PATRONI_VERSION --upgrade \
175121
&& mkdir /usr/lib/postgresql \
176122
&& curl -sL https://github.com/cybertec-postgresql/pg_permissions/archive/$PG_PERMISSIONS_COMMIT.tar.gz | tar xz \
177123
#&& curl -sL https://github.com/x4m/pg_tm_aux/archive/$PG_TM_AUX_COMMIT.tar.gz | tar xz \
@@ -349,7 +295,7 @@ RUN for version in $PG_SUPPORTED_VERSIONS; do \
349295
done
350296

351297
# Clean Up Packages binutils glibc-devel glibc-static
352-
RUN ${PACKAGER} -y remove python3-pip python3-wheel python3-dev git patchutils flatpak glibc-static gcc glibc-devel \
298+
RUN ${PACKAGER} -y remove python3.11-pip python3.11-wheel python3.11-dev git patchutils flatpak glibc-static gcc glibc-devel \
353299
#&& ${PACKAGER} -y autoremove \
354300
&& ${PACKAGER} -y clean dbcache \
355301
&& ${PACKAGER} -y clean all;

launcher/pgbackrest/launch.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ PGBACKREST_PATH=${PGBACKREST_PATH:-'/opt/pgbackrest'}
66
source "${PGBACKREST_PATH}/bin/shell_lib.sh"
77
output_info "Start pgBackRest-PreCondition-Check"
88

9-
if [ "$MODE" == "pgbackrest" ] && [ "$COMMAND" == "backup" ]; then
9+
if [ "$MODE" == "pgbackrest" ] && [ "$COMMAND" == "repo-host" ]; then
10+
output_info "pgBackRest: Start Repo-Host"
11+
pgbackrest server
12+
13+
elif [ "$MODE" == "pgbackrest" ] && [ "$COMMAND" == "backup" ]; then
1014
output_info "pgBackRest: Backup-Job found"
1115
source "${PGBACKREST_PATH}/bin/backup/start.sh"
1216
output_success "pgBackRest: Backup-Job completed"

scripts/configure_spilo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
PROVIDER_LOCAL = "local"
3333
PROVIDER_UNSUPPORTED = "unsupported"
3434
USE_KUBERNETES = os.environ.get('KUBERNETES_SERVICE_HOST') is not None
35-
KUBERNETES_DEFAULT_LABELS = '{"application": "cpo"}'
35+
KUBERNETES_DEFAULT_LABELS = '{"application": "cpo", "member.cpo.opensource.cybertec.at/type": "postgres"}'
3636
PATRONI_DCS = ('kubernetes', 'zookeeper', 'exhibitor', 'consul', 'etcd3', 'etcd')
3737
AUTO_ENABLE_WALG_RESTORE = ('WAL_S3_BUCKET', 'WALE_S3_PREFIX', 'WALG_S3_PREFIX', 'WALG_AZ_PREFIX', 'WALG_SSH_PREFIX')
3838
WALG_SSH_NAMES = ['WALG_SSH_PREFIX', 'SSH_PRIVATE_KEY_PATH', 'SSH_USERNAME', 'SSH_PORT']
@@ -1082,7 +1082,7 @@ def main():
10821082

10831083
if provider == PROVIDER_LOCAL and not any(1 for key in config.keys() if key in PATRONI_DCS):
10841084
link_runit_service(placeholders, 'etcd')
1085-
config['etcd'] = {'host': '127.0.0.1:2379'}
1085+
config['etcd3'] = {'host': '127.0.0.1:2379'}
10861086

10871087
pgdata = config['postgresql']['data_dir']
10881088
version_file = os.path.join(pgdata, 'PG_VERSION')

scripts/pgbackrest/repo-host/start.sh

Whitespace-only changes.

scripts/post_init.sh

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,25 @@ PGVER=$(psql -d "$2" -XtAc "SELECT pg_catalog.current_setting('server_version_nu
66
if [ "$PGVER" -ge 12 ]; then RESET_ARGS="oid, oid, bigint"; fi
77

88
(
9-
# echo "DO \$\$
10-
# BEGIN
11-
# PERFORM * FROM pg_catalog.pg_authid WHERE rolname = 'admin';
12-
# IF FOUND THEN
13-
# ALTER ROLE admin WITH CREATEDB NOLOGIN NOCREATEROLE NOSUPERUSER NOREPLICATION INHERIT;
14-
# ELSE
15-
# CREATE ROLE admin CREATEDB;
16-
# END IF;
17-
# END;\$\$;
18-
19-
# GRANT cron_admin TO admin;
20-
21-
# DO \$\$
22-
# BEGIN
23-
# PERFORM * FROM pg_catalog.pg_authid WHERE rolname = '$1';
24-
# IF FOUND THEN
25-
# ALTER ROLE $1 WITH NOCREATEDB NOLOGIN NOCREATEROLE NOSUPERUSER NOREPLICATION INHERIT;
26-
# ELSE
27-
# CREATE ROLE $1;
28-
# END IF;
29-
# END;\$\$;"
9+
echo "DO \$\$
10+
BEGIN
11+
PERFORM * FROM pg_catalog.pg_authid WHERE rolname = 'admin';
12+
IF FOUND THEN
13+
ALTER ROLE admin WITH CREATEDB NOLOGIN NOCREATEROLE NOSUPERUSER NOREPLICATION INHERIT;
14+
ELSE
15+
CREATE ROLE admin CREATEDB;
16+
END IF;
17+
END;\$\$;
18+
19+
DO \$\$
20+
BEGIN
21+
PERFORM * FROM pg_catalog.pg_authid WHERE rolname = '$1';
22+
IF FOUND THEN
23+
ALTER ROLE $1 WITH NOCREATEDB NOLOGIN NOCREATEROLE NOSUPERUSER NOREPLICATION INHERIT;
24+
ELSE
25+
CREATE ROLE $1;
26+
END IF;
27+
END;\$\$;"
3028

3129
while IFS= read -r db_name; do
3230
echo "\c ${db_name}"
@@ -50,8 +48,8 @@ while IFS= read -r db_name; do
5048
fi
5149
fi
5250
sed "s/:HUMAN_ROLE/$1/" create_user_functions.sql
53-
echo "CREATE EXTENSION IF NOT EXISTS pg_stat_statements SCHEMA public;
54-
ALTER EXTENSION set_user UPDATE;
51+
echo "CREATE EXTENSION IF NOT EXISTS pg_stat_statements SCHEMA public;"
52+
# ALTER EXTENSION set_user UPDATE;
5553
# GRANT EXECUTE ON FUNCTION public.set_user(text) TO admin;
5654
# GRANT EXECUTE ON FUNCTION public.pg_stat_statements_reset($RESET_ARGS) TO admin;"
5755

scripts/spilo_commons.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
extensions = {
1515
'timescaledb': (13, 16, False, True),
1616
'pg_partman': (13, 16, False, True),
17-
'pg_stat_statements': (14, 16, True, True)
17+
'pg_stat_statements': (34, 16, True, True),
18+
'pgaudit' : (13, 16, True, True)
1819
}
1920

2021
def adjust_extensions(old, version, extwlist=False):

0 commit comments

Comments
 (0)