Clean up document and make config more generic

This commit is contained in:
Dan Milne
2025-02-19 19:12:44 +11:00
parent 5dd89d3621
commit ce9b79f612
3 changed files with 17 additions and 5 deletions

View File

@@ -1,5 +1,9 @@
# Multi Database PostgreSQL with PGBouncer # Multi Database PostgreSQL with PGBouncer
This Compose project will let you run multiple database within one PostgreSQL container. It's based on (Cristian Angulo)[https://dev.to/nietzscheson/multiples-postgres-databases-in-one-service-with-docker-compose-4fdf]'s post on the subject.
It also starts up a PGBouncer.
## ENV file ## ENV file
Create a .env file with the following keys: Create a .env file with the following keys:
@@ -26,3 +30,12 @@ Alternatively, bind mount a local directory for PostgreSQL to use.
## Logging ## Logging
This configuration will log to a mounted volume, using PostgreSQL logging, and not to Stderr / Docker logging as per the default image. This configuration will log to a mounted volume, using PostgreSQL logging, and not to Stderr / Docker logging as per the default image.
## PGBouncer
Add PGBouncer accounts with:
```bash
./generate-userlist pgb_admin >> userlist.txt
```
Update `pgbouncer.ini` adding the databases defined in POSTGRES_MULTIPLE_DATABASES to the `[databases]` section.

View File

@@ -1,5 +1,5 @@
services: services:
solid-pg: postgres:
restart: always restart: always
image: postgres:17 image: postgres:17
environment: environment:
@@ -21,7 +21,7 @@ services:
restart: always restart: always
image: edoburu/pgbouncer:latest image: edoburu/pgbouncer:latest
depends_on: depends_on:
- solid-pg - postgres
ports: ports:
- "${HOST_IP}:6432:5432" - "${HOST_IP}:6432:5432"
volumes: volumes:

View File

@@ -1,12 +1,11 @@
[databases] [databases]
solid_cache = host=solid-pg port=5432 dbname=solid_cache user=postgres password=Zie6ioloo5ehi0oosei4fahg database1 = host=solid-pg port=5432 dbname=solid_cache user=postgres password=somepassword
solid_queue = host=solid-pg port=5432 dbname=solid_queue user=postgres password=Zie6ioloo5ehi0oosei4fahg database1 = host=solid-pg port=5432 dbname=solid_queue user=postgres password=somepassword
[pgbouncer] [pgbouncer]
listen_addr = 0.0.0.0 listen_addr = 0.0.0.0
listen_port = 5432 listen_port = 5432
#auth_type = scram-sha-256
auth_type = md5 auth_type = md5
auth_file = /etc/pgbouncer/userlist.txt auth_file = /etc/pgbouncer/userlist.txt
logfile = /var/log/pgbouncer/pgbouncer.log logfile = /var/log/pgbouncer/pgbouncer.log