2022-12-23 21:16:03 +08:00
|
|
|
# From https://github.com/docker-library/postgres/blob/master/15/alpine/Dockerfile
|
2023-02-13 21:03:56 +08:00
|
|
|
FROM postgres:15.2-alpine
|
2021-11-30 18:20:42 +08:00
|
|
|
|
2023-05-03 22:34:27 +08:00
|
|
|
COPY --chmod=775 start.sh /usr/bin/start.sh
|
|
|
|
COPY --chmod=775 healthcheck.sh /usr/bin/healthcheck.sh
|
|
|
|
COPY --chmod=775 init-user-db.sh /docker-entrypoint-initdb.d/init-user-db.sh
|
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
RUN set -ex; \
|
2023-05-03 22:34:27 +08:00
|
|
|
apk add --no-cache bash openssl shadow grep mawk; \
|
|
|
|
\
|
|
|
|
# We need to use the same gid and uid as on old installations
|
2022-02-10 02:34:43 +08:00
|
|
|
deluser postgres; \
|
|
|
|
groupmod -g 9999 ping; \
|
|
|
|
addgroup -g 999 -S postgres; \
|
2023-05-03 22:34:27 +08:00
|
|
|
adduser -u 999 -S -D -G postgres -H -h /var/lib/postgresql -s /bin/sh postgres; \
|
2023-05-11 20:13:56 +08:00
|
|
|
apk del --no-cache shadow; \
|
2023-05-03 22:34:27 +08:00
|
|
|
\
|
2022-02-10 04:59:51 +08:00
|
|
|
# Fix default permissions
|
|
|
|
chown -R postgres:postgres /var/lib/postgresql; \
|
|
|
|
chown -R postgres:postgres /var/run/postgresql; \
|
2023-05-03 22:34:27 +08:00
|
|
|
chown -R postgres:postgres "$PGDATA"; \
|
|
|
|
\
|
|
|
|
mkdir /mnt/data; \
|
2021-11-30 18:20:42 +08:00
|
|
|
chown postgres:postgres /mnt/data;
|
2023-05-03 22:34:27 +08:00
|
|
|
\
|
2021-11-30 18:20:42 +08:00
|
|
|
# Give root a random password
|
2023-05-03 22:34:27 +08:00
|
|
|
echo "root:$(openssl rand -base64 12)" | chpasswd
|
2021-11-30 18:20:42 +08:00
|
|
|
|
2023-05-11 20:13:56 +08:00
|
|
|
VOLUME /mnt/data
|
|
|
|
|
2021-11-30 18:20:42 +08:00
|
|
|
USER postgres
|
|
|
|
ENTRYPOINT ["start.sh"]
|
2022-08-25 21:06:23 +08:00
|
|
|
|
2023-01-03 01:16:12 +08:00
|
|
|
HEALTHCHECK CMD healthcheck.sh
|
2023-01-30 22:33:12 +08:00
|
|
|
LABEL com.centurylinklabs.watchtower.monitor-only="true"
|