2024-02-16 23:21:18 +08:00
|
|
|
# syntax=docker/dockerfile:latest
|
2022-12-23 21:16:03 +08:00
|
|
|
# From https://github.com/docker-library/postgres/blob/master/15/alpine/Dockerfile
|
2024-02-13 20:20:34 +08:00
|
|
|
FROM postgres:15.6-alpine
|
2021-11-30 18:20:42 +08:00
|
|
|
|
2023-05-11 20:17:54 +08:00
|
|
|
COPY --chmod=775 start.sh /start.sh
|
|
|
|
COPY --chmod=775 healthcheck.sh /healthcheck.sh
|
2023-05-03 22:34:27 +08:00
|
|
|
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-06-07 23:26:44 +08:00
|
|
|
apk add --no-cache \
|
|
|
|
bash \
|
|
|
|
openssl \
|
|
|
|
shadow \
|
|
|
|
grep; \
|
2023-05-03 22:34:27 +08:00
|
|
|
\
|
|
|
|
# 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-06-26 22:31:32 +08:00
|
|
|
chmod -R 777 /var/run/postgresql; \
|
2023-05-03 22:34:27 +08:00
|
|
|
chown -R postgres:postgres "$PGDATA"; \
|
|
|
|
\
|
|
|
|
mkdir /mnt/data; \
|
2023-05-16 22:28:01 +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-06-07 23:26:44 +08:00
|
|
|
echo "root:$(openssl rand -base64 12)" | chpasswd; \
|
|
|
|
apk --no-cache del openssl;
|
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
|
2023-05-11 20:17:54 +08:00
|
|
|
ENTRYPOINT ["/start.sh"]
|
2022-08-25 21:06:23 +08:00
|
|
|
|
2023-05-11 20:17:54 +08:00
|
|
|
HEALTHCHECK CMD /healthcheck.sh
|
2023-06-26 06:56:08 +08:00
|
|
|
LABEL com.centurylinklabs.watchtower.enable="false"
|