Configure PostgreSQL to accept connections from any IP address

This commit is contained in:
João Pedro Toledo Goncalves 2026-02-03 12:51:12 -03:00
parent b77b6689f0
commit 1c6883107b
1 changed files with 13 additions and 2 deletions

View File

@ -6,5 +6,16 @@ COPY backup_global_20260130_184353.sql /tmp/restore.sql
# Set correct permissions
RUN chmod 644 /tmp/restore.sql
# Configure pg_hba.conf to accept connections from any host
RUN echo "host all all 0.0.0.0/0 scram-sha-256" >> /usr/local/share/postgresql/pg_hba.conf.sample
# Create custom pg_hba.conf to allow connections from anywhere
RUN echo "# Allow connections from any IP address" > /tmp/pg_hba_additions.conf && \
echo "host all all 0.0.0.0/0 scram-sha-256" >> /tmp/pg_hba_additions.conf && \
echo "host all all ::/0 scram-sha-256" >> /tmp/pg_hba_additions.conf
# Copy script to append to pg_hba.conf on startup
COPY <<EOF /docker-entrypoint-initdb.d/00-allow-remote.sh
#!/bin/bash
echo "host all all 0.0.0.0/0 scram-sha-256" >> /var/lib/postgresql/data/pg_hba.conf
echo "host all all ::/0 scram-sha-256" >> /var/lib/postgresql/data/pg_hba.conf
EOF
RUN chmod +x /docker-entrypoint-initdb.d/00-allow-remote.sh