switch to s6-rc

This commit is contained in:
Sebastian Hugentobler 2022-02-13 08:23:50 +01:00
parent 5103f5b01f
commit 05459d3577
Signed by: shu
GPG Key ID: BB32CF3CA052C2F0
16 changed files with 31 additions and 20 deletions

View File

@ -1,8 +1,11 @@
FROM thallian/confd-env:latest
ENV PGDATA /var/lib/postgresql/data
ENV PGDATA=/var/lib/postgresql/data
ENV S6_KEEP_ENV=1
RUN apk add --no-cache postgresql14 postgresql14-contrib
RUN apk add --no-cache \
postgresql14 \
postgresql14-contrib
RUN mkdir -p /run/postgresql && mkdir -p $PGDATA
RUN chown -R postgres /run/postgresql && chown -R postgres $PGDATA

9
rootfs/bin/db-password Executable file
View File

@ -0,0 +1,9 @@
#!/command/with-contenv sh
echo "local all all trust" > "$PGDATA/pg_hba.conf"
pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w start
psql --command "ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';"
pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w stop

5
rootfs/bin/initdb Executable file
View File

@ -0,0 +1,5 @@
#!/command/with-contenv sh
if [ ! -f "/var/lib/postgresql/data/PG_VERSION" ]; then
s6-setuidgid postgres initdb --username=postgres
fi

View File

@ -1,5 +0,0 @@
#!/usr/bin/with-contenv sh
if [ ! -f ${PGDATA}/PG_VERSION ]; then
s6-setuidgid postgres initdb --username=postgres
fi

View File

@ -1,11 +0,0 @@
#!/usr/bin/with-contenv sh
cat <<EOF > /var/lib/postgresql/data/pg_hba.conf
local all all trust
EOF
s6-setuidgid postgres pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w start
s6-setuidgid postgres psql --command "ALTER USER postgres WITH PASSWORD '${POSTGRES_PASSWORD}';"
s6-setuidgid postgres pg_ctl -D "$PGDATA" -o "-c listen_addresses='localhost'" -w stop

View File

@ -1 +0,0 @@
/var/lib/postgresql true postgres 0600 0700

View File

@ -0,0 +1,2 @@
initdb
db-password

View File

@ -0,0 +1 @@
initdb

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
s6-setuidgid postgres db-password

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
s6-setuidgid postgres initdb

View File

@ -0,0 +1,3 @@
initdb
db-password
confd

View File

@ -1,4 +1,4 @@
#!/usr/bin/with-contenv sh
#!/command/with-contenv sh
exec s6-setuidgid postgres postgres \
-D $PGDATA \

View File

@ -0,0 +1 @@
longrun