File tree Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Expand file tree Collapse file tree 3 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ RUN curl -sSLf https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-${
36
36
groupadd -g 70 postgres && \
37
37
adduser postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh && \
38
38
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 \
40
40
postgresql12-server && \
41
41
# The removal of /usr/share/zoneinfo from UBI minimal images is intentional.
42
42
# 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/
65
65
RUN /usr/local/bin/start-db.sh
66
66
USER root
67
67
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/*
69
69
USER 70:70
70
70
ENV DATABASE_ALREADY_EXISTS=true
71
71
ENTRYPOINT ["custom-entrypoint.sh" ]
Original file line number Diff line number Diff line change 6
6
7
7
set -e
8
8
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
+
9
15
echo " Starting database..."
10
16
POSTGRES_PASSWORD=postgres /usr/local/bin/docker-entrypoint.sh postgres -c config_file=/etc/postgresql.conf &
11
17
@@ -25,7 +31,7 @@ if [ "$POSTGRES_USER" != "postgres" ]; then
25
31
fi
26
32
27
33
echo " Stopping database..."
28
- pg_ctl -D /var/lib/postgresql/data/pgdata - w stop
34
+ pg_ctl -w stop
29
35
30
36
# Now we can start the database for real. But we will
31
37
# forward any arguments to the actual entrypoint script
Original file line number Diff line number Diff line change @@ -5,14 +5,24 @@ set -eu
5
5
echo " Creating postgres.conf for initialization..."
6
6
cat << EOF > /tmp/postgres.conf
7
7
listen_addresses = '*'
8
+ max_wal_size = 1GB
8
9
EOF
9
10
11
+ echo " Creating temporary PGDATA directory..."
12
+ mkdir -p /tmp/data
13
+
10
14
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
12
16
13
17
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
15
19
sleep 1
16
20
done
17
21
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
You can’t perform that action at this time.
0 commit comments