-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
40 lines (38 loc) · 1.45 KB
/
Copy pathdocker-compose.yml
File metadata and controls
40 lines (38 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Production-like local stack: PostgreSQL behind a PgBouncer connection pooler.
#
# The Rails app (run on the host via JRuby) connects to PgBouncer on localhost:6432,
# which pools transactions against the internal `postgres` service. This mirrors a
# typical production topology where the app never talks to Postgres directly.
#
# Bring it up with: docker-compose up -d
# Drive the resilience simulation with: bin/pgbouncer_resilience
name: myapp-pgbouncer
services:
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: myapp
POSTGRES_PASSWORD: myapp
POSTGRES_DB: myapp_development
# Not published on the host: only PgBouncer (and `docker-compose exec`) reach it,
# which also avoids clashing with any local Postgres already on 5432.
expose:
- "5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U myapp -d myapp_development"]
interval: 2s
timeout: 3s
retries: 30
pgbouncer:
image: edoburu/pgbouncer:latest
depends_on:
postgres:
condition: service_healthy
# Run PgBouncer directly against our mounted config instead of the image's
# env-driven template, so we control pool_mode, lifetimes, and admin access.
entrypoint: ["pgbouncer", "/etc/pgbouncer/pgbouncer.ini"]
volumes:
- ./docker/pgbouncer/pgbouncer.ini:/etc/pgbouncer/pgbouncer.ini:ro
- ./docker/pgbouncer/userlist.txt:/etc/pgbouncer/userlist.txt:ro
ports:
- "6432:6432"