Trying to set up a Django multicontainer application for local development purposes. I haven't found a way to customize pg_hba.conf and postgresql.conf directly from the compose file. I don't want to rely on external scripts or even external files to be copied to the container since the pg_hba.conf and postgresql.conf are rather simple and additional files would add clutter in the project directory. Having a second Dockerfile for the database also is not an optimal solution for me since, as stated, I just need a few lines to be configured/uncommented on those target files.
Below, the current configuration for my compose file.
version: '3.8'
services:
#-------------------------------------------------------#
# postgres
suapdb:
hostname: 'suapdb'
ports:
- "5432:5432"
environment:
POSTGRES_USER: postgres
POSTGRES_HOST_AUTH_METHOD: trust
POSTGRES_PASSWORD: ''
POSTGRES_DB: suap_dev
PGDATA: /var/lib/postgresql/data/
networks:
- suap_dev_net
volumes:
- postgres:/var/lib/postgresql/data
command: >
ash -c "echo host all all 0.0.0.0/0 trust > /var/lib/postgresql/data/pg_hba.conf &&
echo local all postgres trust >> /var/lib/postgresql/data/pg_hba.conf &&
echo local all all ident >> /var/lib/postgresql/data/pg_hba.conf &&
echo listen_addresses = \'*\' >> /var/lib/postgresql/data/postgresql.conf"
image: postgres:13-alpine
The commented lines on the suapdb service are the ones I hoped would work out (as I have seen in other posts) but it hasn't.
Any contribution appreciated.