Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
118 lines (113 loc) · 3.55 KB
/
Copy pathdocker-compose.yml
File metadata and controls
118 lines (113 loc) · 3.55 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
services:
valkey:
image: valkey/valkey:8-alpine
container_name: valkey
ports:
- "127.0.0.1:6379:6379"
volumes:
- valkey_data:/data
command: valkey-server --appendonly yes
restart: unless-stopped
# Fast node - primary database for approved queries
postgres-fast:
image: postgres:16-alpine
container_name: pgproxy-fast
ports:
- "127.0.0.1:5433:5432"
environment:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: testdb
volumes:
- postgres_fast_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U testuser -d testdb"]
interval: 5s
timeout: 5s
retries: 5
# Shunt node - slow/penalty node for rejected queries
# Same schema as fast node
postgres-shunt:
image: postgres:16-alpine
container_name: pgproxy-shunt
ports:
- "127.0.0.1:5434:5432"
environment:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: testdb
volumes:
- postgres_shunt_data:/var/lib/postgresql/data
- ./init.sql:/docker-entrypoint-initdb.d/init.sql:ro
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U testuser -d testdb"]
interval: 5s
timeout: 5s
retries: 5
# Reporter database - stores query issues
# Schema managed by proxy migrations (internal/db/migrations)
postgres-reporter:
image: postgres:16-alpine
container_name: pgproxy-reporter
ports:
- "127.0.0.1:5435:5432"
environment:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: testdb
volumes:
- postgres_reporter_data:/var/lib/postgresql/data
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -U testuser -d testdb"]
interval: 5s
timeout: 5s
retries: 5
pgproxy:
build: .
container_name: pgproxy
ports:
- "5432:5432"
- "8080:8080"
environment:
# Connect to fast node by default
PG_BACKEND_URL: ${PG_BACKEND_URL:-postgres://testuser:testpass@postgres-fast:5432/testdb?sslmode=disable}
# Shunt node for rejected queries (shunt mode)
SHUNT_NODE_URL: ${SHUNT_NODE_URL:-postgres://testuser:testpass@postgres-shunt:5432/testdb?sslmode=disable}
# Reporter database URL (migrations run automatically)
REPORTER_DB_URL: ${REPORTER_DB_URL:-postgres://testuser:testpass@postgres-reporter:5432/testdb?sslmode=disable}
# Valkey/Redis URL for approval cache
VALKEY_URL: ${VALKEY_URL:-redis://valkey:6379}
# AWS credentials for Bedrock
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_SESSION_TOKEN: ${AWS_SESSION_TOKEN}
BEDROCK_AWS_REGION: ${BEDROCK_AWS_REGION:-${AWS_REGION:-eu-west-1}}
# Proxy mode: non-blocking, blocking, shunt
PROXY_MODE: ${PROXY_MODE:-non-blocking}
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
valkey:
condition: service_started
postgres-fast:
condition: service_healthy
postgres-shunt:
condition: service_healthy
postgres-reporter:
condition: service_healthy
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/ready || exit 1"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
volumes:
valkey_data:
postgres_fast_data:
postgres_shunt_data:
postgres_reporter_data: