Robustly generate pg_hba.conf in /tmp during startup

This commit is contained in:
2026-08-11 13:02:57 +05:30
parent 02207d6b80
commit 5b8a35f46c
+9 -2
View File
@@ -9,11 +9,18 @@ services:
FORCE_RESTART: 4 FORCE_RESTART: 4
ports: ports:
- "5432:5432" - "5432:5432"
command: ["postgres", "-c", "hba_file=/etc/postgresql/pg_hba.conf"] entrypoint: /bin/sh
command: >
-c "
echo 'local all all trust' > /tmp/pg_hba.conf;
echo 'host all all 0.0.0.0/0 md5' >> /tmp/pg_hba.conf;
echo 'host all all 0.0.0.0/0 scram-sha-256' >> /tmp/pg_hba.conf;
chown postgres:postgres /tmp/pg_hba.conf || true;
exec /usr/local/bin/docker-entrypoint.sh postgres -c hba_file=/tmp/pg_hba.conf
"
volumes: volumes:
- ./db:/docker-entrypoint-initdb.d - ./db:/docker-entrypoint-initdb.d
- pgdata:/var/lib/postgresql/data - pgdata:/var/lib/postgresql/data
- ./pg_hba.conf:/etc/postgresql/pg_hba.conf
api: api: