-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
197 lines (185 loc) · 5.49 KB
/
Copy pathdocker-compose.yml
File metadata and controls
197 lines (185 loc) · 5.49 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
version: '3.8'
# Common limits: 8 services * 0.5 CPU = 4 CPUs | 8 services * 1G = 8GB RAM
x-resources: &default-resources
deploy:
resources:
limits:
cpus: '0.5'
memory: 1G
services:
postgres:
image: postgres:15-alpine
environment:
POSTGRES_USER: ${DB_USER:-postgres}
POSTGRES_PASSWORD: ${DB_PASS:-postgres}
POSTGRES_DB: ${DB_NAME:-subtrackr}
ports:
- "${COMPOSE_PORT_POSTGRES:-5432}:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-postgres} -d ${DB_NAME:-subtrackr}"]
interval: 5s
timeout: 5s
retries: 5
<<: *default-resources
# Issue #600: PgBouncer transaction-pooling proxy for serverless connection
# multiplexing. App / serverless handlers -> pgbouncer :6432 -> postgres :5432.
# Credentials are interpolated from .env (see .env.example) — never hardcoded.
pgbouncer:
image: edoburu/pgbouncer:1.23.1
depends_on:
postgres:
condition: service_healthy
environment:
DB_HOST: postgres
DB_PORT: "5432"
DB_USER: ${DB_USER:-postgres}
DB_PASSWORD: ${DB_PASS:-postgres}
DB_NAME: ${DB_NAME:-subtrackr}
# Transaction pooling: small server pool fans out to many clients.
POOL_MODE: transaction
AUTH_TYPE: scram-sha-256
MAX_CLIENT_CONN: "500"
DEFAULT_POOL_SIZE: "50"
MIN_POOL_SIZE: "5"
RESERVE_POOL_SIZE: "10"
# Prepared-statement support in transaction mode (PgBouncer >= 1.21).
MAX_PREPARED_STATEMENTS: "256"
# Force-close server connections abandoned past the leak threshold (30s).
SERVER_IDLE_TIMEOUT: "30"
QUERY_TIMEOUT: "30"
ports:
- "${COMPOSE_PORT_PGBOUNCER:-6432}:6432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -h 127.0.0.1 -p 6432 -U ${DB_USER:-postgres}"]
interval: 5s
timeout: 3s
retries: 10
<<: *default-resources
redis:
image: redis:7-alpine
ports:
- "${COMPOSE_PORT_REDIS:-6379}:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
<<: *default-resources
soroban-standalone:
image: stellar/quickstart:testing
command: --standalone --enable-soroban-rpc
ports:
- "${COMPOSE_PORT_SOROBAN:-8000}:8000"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/"]
interval: 10s
timeout: 5s
retries: 5
<<: *default-resources
backend:
build:
context: .
dockerfile: docker/backend.Dockerfile
ports:
- "${COMPOSE_PORT_BACKEND:-3000}:3000"
environment:
- NODE_ENV=development
- DB_HOST=postgres
- DB_PORT=5432
- DB_USER=${DB_USER:-postgres}
- DB_PASS=${DB_PASS:-postgres}
- DB_NAME=${DB_NAME:-subtrackr}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
- SOROBAN_RPC_URL=${SOROBAN_RPC_URL:-http://soroban-standalone:8000/rpc}
command: ["npx", "--yes", "ts-node-dev", "--respawn", "--transpile-only", "backend/server/start.ts"]
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
<<: *default-resources
workers:
build:
context: .
dockerfile: docker/backend.Dockerfile
environment:
- NODE_ENV=development
- DB_HOST=postgres
- DB_USER=${DB_USER:-postgres}
- DB_PASS=${DB_PASS:-postgres}
- DB_NAME=${DB_NAME:-subtrackr}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
command: ["npx", "--yes", "ts-node-dev", "--respawn", "--transpile-only", "backend/billing/jobs/billingJobQueue.ts"]
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
<<: *default-resources
webhook-dispatcher:
build:
context: .
dockerfile: docker/backend.Dockerfile
environment:
- NODE_ENV=development
- DB_HOST=postgres
- DB_USER=${DB_USER:-postgres}
- DB_PASS=${DB_PASS:-postgres}
- DB_NAME=${DB_NAME:-subtrackr}
- REDIS_URL=${REDIS_URL:-redis://redis:6379}
command: ["npx", "--yes", "ts-node-dev", "--respawn", "--transpile-only", "backend/webhook/jobs/webhookDeliveryJob.ts"]
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
<<: *default-resources
ml-service:
build:
context: .
dockerfile: docker/ml.Dockerfile
ports:
- "${COMPOSE_PORT_ML:-8001}:8000"
environment:
- DB_HOST=postgres
command: ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
depends_on:
postgres:
condition: service_healthy
<<: *default-resources
mobile:
build:
context: .
dockerfile: docker/backend.Dockerfile
ports:
- "${COMPOSE_PORT_EXPO:-8081}:8081"
environment:
- NODE_ENV=development
- EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0
- REACT_NATIVE_PACKAGER_HOSTNAME=${HOST_IP:-127.0.0.1}
command: ["npx", "expo", "start"]
profiles:
- mobile
<<: *default-resources
seed:
image: postgres:15-alpine
environment:
- PGHOST=postgres
- PGUSER=${DB_USER:-postgres}
- PGPASSWORD=${DB_PASS:-postgres}
- PGDATABASE=${DB_NAME:-subtrackr}
volumes:
- ./docker/seed:/seed
depends_on:
postgres:
condition: service_healthy
command: ["psql", "-f", "/seed/seed.sql"]
profiles:
- tools
volumes:
postgres_data:
redis_data: