Skip to content

Commit 80f102f

Browse files
committed
ROX-19980 fix
1 parent 9e85cd1 commit 80f102f

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

image/db/rhel/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RUN curl -sSLf https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-${
3636
groupadd -g 70 postgres && \
3737
adduser postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh && \
3838
microdnf install \
39-
ca-certificates libicu systemd-sysv glibc-locale-source glibc-langpack-en \
39+
ca-certificates tar libicu systemd-sysv glibc-locale-source glibc-langpack-en \
4040
postgresql12-server && \
4141
# The removal of /usr/share/zoneinfo from UBI minimal images is intentional.
4242
# After building the image, the image is reduced in size as much as possible,
@@ -65,7 +65,7 @@ COPY scripts/start-db.sh /usr/local/bin/
6565
RUN /usr/local/bin/start-db.sh
6666
USER root
6767
RUN rm -rf /usr/local/bin/start-db.sh && \
68-
rm -rf /docker-entrypoint-initdb.d/definitions.sql
68+
rm -rf /docker-entrypoint-initdb.d/*
6969
USER 70:70
7070
ENV DATABASE_ALREADY_EXISTS=true
7171
ENTRYPOINT ["custom-entrypoint.sh"]

image/db/rhel/scripts/custom-entrypoint.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
set -e
88

9+
echo "Creating /var/lib/postgresql/data/pgdata..."
10+
mkdir -p /var/lib/postgresql/data/pgdata
11+
12+
echo "Uncompressing into /var/lib/pgsql/data/pgdata..."
13+
tar -xzf /tmp/data.tar.gz -C /var/lib/postgresql/data/pgdata
14+
915
echo "Starting database..."
1016
POSTGRES_PASSWORD=postgres /usr/local/bin/docker-entrypoint.sh postgres -c config_file=/etc/postgresql.conf &
1117

@@ -25,7 +31,7 @@ if [ "$POSTGRES_USER" != "postgres" ]; then
2531
fi
2632

2733
echo "Stopping database..."
28-
pg_ctl -D /var/lib/postgresql/data/pgdata -w stop
34+
pg_ctl -w stop
2935

3036
# Now we can start the database for real. But we will
3137
# forward any arguments to the actual entrypoint script

image/db/rhel/scripts/start-db.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@ set -eu
55
echo "Creating postgres.conf for initialization..."
66
cat <<EOF > /tmp/postgres.conf
77
listen_addresses = '*'
8+
max_wal_size = 1GB
89
EOF
910

11+
echo "Creating temporary PGDATA directory..."
12+
mkdir -p /tmp/data
13+
1014
echo "Starting database..."
11-
POSTGRES_PASSWORD=postgres /usr/local/bin/docker-entrypoint.sh postgres -c config_file=/tmp/postgres.conf
15+
PGDATA=/tmp/data POSTGRES_PASSWORD=postgres /usr/local/bin/docker-entrypoint.sh postgres -c config_file=/tmp/postgres.conf
1216

1317
echo "Waiting for database to stop..."
14-
while [ -f /var/lib/postgresql/data/pgdata/postmaster.pid ]; do
18+
while [ -f /tmp/data/pgdata/postmaster.pid ]; do
1519
sleep 1
1620
done
1721

18-
rm /tmp/postgres.conf
22+
rm /tmp/postgres.conf
23+
24+
echo "Compressing database data folder..."
25+
tar -czf /tmp/data.tar.gz -C /tmp/data .
26+
27+
echo "Removing temporary PGDATA directory..."
28+
rm -rf /tmp/data

0 commit comments

Comments
 (0)