2024-02-16 23:21:18 +08:00
|
|
|
# syntax=docker/dockerfile:latest
|
2024-12-16 19:04:52 +08:00
|
|
|
# From https://github.com/docker-library/postgres/blob/master/16/alpine3.21/Dockerfile
|
2024-11-25 13:10:48 +08:00
|
|
|
FROM postgres:16.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; \
|
2024-04-17 23:52:42 +08:00
|
|
|
apk upgrade --no-cache -a; \
|
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; \
|
2024-07-12 00:22:39 +08:00
|
|
|
apk --no-cache del openssl; \
|
|
|
|
\
|
|
|
|
# Get rid of unused binaries
|
2024-07-12 16:36:14 +08:00
|
|
|
rm -f /usr/local/bin/gosu /usr/local/bin/su-exec;
|
2021-11-30 18:20:42 +08:00
|
|
|
|
2023-05-11 20:13:56 +08:00
|
|
|
VOLUME /mnt/data
|
|
|
|
|
2024-11-06 21:29:18 +08:00
|
|
|
USER 999
|
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"
|