From cf76752894d07c0bd2400551d48e2d966b5810ce Mon Sep 17 00:00:00 2001 From: Sarah Vaupel Date: Mon, 23 Sep 2024 00:18:13 +0200 Subject: [PATCH] build(docker/database): work on postgres config --- docker/database/Dockerfile | 3 +++ docker/database/initdb.sh | 2 +- docker/database/pg_hba.conf | 3 ++- docker/database/postgresql.conf | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docker/database/Dockerfile b/docker/database/Dockerfile index d486280bf..c726e2fbe 100644 --- a/docker/database/Dockerfile +++ b/docker/database/Dockerfile @@ -3,6 +3,9 @@ FROM docker.io/postgres:12 # Allow for connecting to database without password authentication ENV POSTGRES_HOST_AUTH_METHOD=trust +RUN cp /mnt/fradrive/docker/database/pg_hba.conf /docker-entrypoint-initdb.d/pg_hba.conf && chown postgres:postgres /docker-entrypoint-initdb.d/pg_hba.conf +RUN cp /mnt/fradrive/docker/database/postgresql.conf /docker-entrypoint-initdb.d/postgresql.conf && chown postgres:postgres /docker-entrypoint-initdb.d/postgresql.conf + RUN cp /mnt/fradrive/docker/database/schema.sql /schema.sql && chown postgres:postgres /schema.sql RUN cp /mnt/fradrive/docker/database/initdb.sh /etc/fradrive-db && chmod 755 /etc/fradrive-db diff --git a/docker/database/initdb.sh b/docker/database/initdb.sh index 775e14d4c..ec081483c 100644 --- a/docker/database/initdb.sh +++ b/docker/database/initdb.sh @@ -2,7 +2,7 @@ # Init and start the postgres daemon initdb --no-locale -pg_ctl start -w -o "-c listen_addresses=0.0.0.0 -c unix_socket_permissions=0700 -c max_connections=9990 -c shared_preload_libraries=pg_stat_statements -c session_preload_libraries=auto_explain -c auto_explain.log_min_duration=100ms" # COPY postgresql.conf and postgres_hba.conf resulted in error (Invalid data directory) +pg_ctl start -w -o "-c listen_addresses='*' -c unix_socket_permissions=0700 -c max_connections=9990 -c shared_preload_libraries=pg_stat_statements -c session_preload_libraries=auto_explain -c auto_explain.log_min_duration=100ms" POSTGRID=`cat /var/lib/postgresql/data/postmaster.pid | perl -le '<>=~m#(\d+)# and print $1'` # Create uniworx and uniworx_test database diff --git a/docker/database/pg_hba.conf b/docker/database/pg_hba.conf index a5e9c7250..da2e4afd1 100644 --- a/docker/database/pg_hba.conf +++ b/docker/database/pg_hba.conf @@ -1 +1,2 @@ -local all all trust \ No newline at end of file +host all all ::1/128 md5 +host all postgres 127.0.0.1/32 md5 \ No newline at end of file diff --git a/docker/database/postgresql.conf b/docker/database/postgresql.conf index 0bccfecc3..a2f917845 100644 --- a/docker/database/postgresql.conf +++ b/docker/database/postgresql.conf @@ -1,4 +1,4 @@ -listen_addresses=0.0.0.0 +listen_addresses='*' unix_socket_permissions=0700 max_connections=9990 shared_preload_libraries=pg_stat_statements