-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
295 lines (273 loc) · 8.54 KB
/
Copy pathdocker-compose.yml
File metadata and controls
295 lines (273 loc) · 8.54 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# docker-compose.yml (root of project)
version: '3.8'
services:
# ============================================================================
# BASE SERVICES (always available)
# ============================================================================
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: ${DB_USER:-topgun}
POSTGRES_PASSWORD: ${DB_PASSWORD:-topgun_dev}
POSTGRES_DB: ${DB_NAME:-topgun}
ports:
- "${DB_PORT:-5432}:5432"
volumes:
- postgres-data:/var/lib/postgresql/data
- ./deploy/init-db.sql:/docker-entrypoint-initdb.d/init.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${DB_USER:-topgun}"]
interval: 5s
timeout: 5s
retries: 5
networks:
- topgun
server:
# Default `docker compose up server` boots TopGun with the embedded redb
# backend on a named volume — no Postgres required, no auth required.
# For a Postgres-backed deployment, set STORAGE_BACKEND=postgres and
# DATABASE_URL via .env (the `postgres` service above is left running so
# the connection string resolves) OR use the `server-postgres` profile
# below for an explicit production-shaped wiring.
build:
context: .
dockerfile: deploy/Dockerfile.server
ports:
- "${SERVER_PORT:-8080}:8080"
- "${CLUSTER_PORT:-9080}:9080"
environment:
RUST_LOG: topgun_server=info
TOPGUN_PORT: 8080
TOPGUN_CLUSTER_PORT: 9080
STORAGE_BACKEND: ${STORAGE_BACKEND:-redb}
TOPGUN_REDB_PATH: /data/topgun.redb
# Dev default: skip auth so `docker compose up server` works without
# generating a key. Override with JWT_SECRET=... for any real deploy.
TOPGUN_NO_AUTH: ${TOPGUN_NO_AUTH:-1}
JWT_SECRET: ${JWT_SECRET:-}
# Only consumed when STORAGE_BACKEND=postgres — harmless otherwise.
DATABASE_URL: postgres://${DB_USER:-topgun}:${DB_PASSWORD:-topgun_dev}@postgres:5432/${DB_NAME:-topgun}
volumes:
- topgun-data:/data
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
networks:
- topgun
# ============================================================================
# PROFILE: admin
# ============================================================================
admin-ui:
build:
context: .
dockerfile: apps/admin-dashboard/Dockerfile
ports:
- "3001:3000"
environment:
VITE_TOPGUN_SERVER_URL: ws://localhost:8080
VITE_TOPGUN_METRICS_URL: http://localhost:9091
profiles: ["admin", "all", "getting-started"]
depends_on:
- server
networks:
- topgun
# ============================================================================
# PROFILE: getting-started (one-command onboarding demo)
# ============================================================================
seed:
build:
context: ./deploy/seed
dockerfile: Dockerfile.seed
environment:
TOPGUN_HOST: server
TOPGUN_PORT: "8080"
# JWT_SECRET is intentionally omitted — the default server config uses
# require_auth: false, so the seed script skips authentication.
profiles: ["getting-started"]
restart: "no"
depends_on:
server:
condition: service_healthy
networks:
- topgun
# ============================================================================
# PROFILE: monitoring
# ============================================================================
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./deploy/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.enable-lifecycle'
profiles: ["monitoring", "all"]
depends_on:
- server
networks:
- topgun
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD: admin
GF_AUTH_ANONYMOUS_ENABLED: "true"
GF_AUTH_ANONYMOUS_ORG_ROLE: "Viewer"
volumes:
- ./deploy/grafana/provisioning:/etc/grafana/provisioning:ro
- ./deploy/grafana/dashboards:/var/lib/grafana/dashboards:ro
- grafana-data:/var/lib/grafana
profiles: ["monitoring", "all"]
depends_on:
- prometheus
networks:
- topgun
# ============================================================================
# PROFILE: dbtools
# ============================================================================
dbgate:
image: dbgate/dbgate:latest
ports:
- "3002:3000"
environment:
CONNECTIONS: |
{
"topgun-postgres": {
"engine": "postgres@dbgate-plugin-postgres",
"server": "postgres",
"port": 5432,
"user": "${DB_USER:-topgun}",
"password": "${DB_PASSWORD:-topgun_dev}",
"database": "${DB_NAME:-topgun}"
}
}
profiles: ["dbtools", "all"]
depends_on:
postgres:
condition: service_healthy
networks:
- topgun
# ============================================================================
# PROFILE: k6 (load testing)
# ============================================================================
k6:
build:
context: ./tests/k6
dockerfile: Dockerfile.k6
volumes:
- ./tests/k6:/scripts:ro
- ./tests/k6/results:/results
environment:
K6_OUT: json=/results/output.json
SERVER_URL: ws://server:8080
profiles: ["k6"]
depends_on:
server:
condition: service_healthy
networks:
- topgun
# ============================================================================
# PROFILE: auto-setup (Rust server with auto-setup profile)
# ============================================================================
server-auto:
build:
context: .
dockerfile: deploy/Dockerfile.server
ports:
- "${SERVER_PORT:-8080}:8080"
- "${METRICS_PORT:-9090}:9090"
environment:
RUST_LOG: topgun_server=info
TOPGUN_PORT: 8080
TOPGUN_METRICS_PORT: 9090
DATABASE_URL: postgres://${DB_USER:-topgun}:${DB_PASSWORD:-topgun_dev}@postgres:5432/${DB_NAME:-topgun}
profiles: ["auto-setup"]
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
networks:
- topgun
# ============================================================================
# PROFILE: cluster (3-node cluster for testing)
# ============================================================================
node-1:
build:
context: .
dockerfile: deploy/Dockerfile.server
ports:
- "10001:8080"
- "11001:9080"
environment:
RUST_LOG: topgun_server=info
NODE_ID: node-1
TOPGUN_PORT: 8080
TOPGUN_CLUSTER_PORT: 9080
TOPGUN_PEERS: node-2:9080,node-3:9080
DATABASE_URL: postgres://${DB_USER:-topgun}:${DB_PASSWORD:-topgun_dev}@postgres:5432/${DB_NAME:-topgun}
profiles: ["cluster"]
depends_on:
postgres:
condition: service_healthy
networks:
- topgun
node-2:
build:
context: .
dockerfile: deploy/Dockerfile.server
ports:
- "10002:8080"
- "11002:9080"
environment:
RUST_LOG: topgun_server=info
NODE_ID: node-2
TOPGUN_PORT: 8080
TOPGUN_CLUSTER_PORT: 9080
TOPGUN_PEERS: node-1:9080,node-3:9080
DATABASE_URL: postgres://${DB_USER:-topgun}:${DB_PASSWORD:-topgun_dev}@postgres:5432/${DB_NAME:-topgun}
profiles: ["cluster"]
depends_on:
postgres:
condition: service_healthy
networks:
- topgun
node-3:
build:
context: .
dockerfile: deploy/Dockerfile.server
ports:
- "10003:8080"
- "11003:9080"
environment:
RUST_LOG: topgun_server=info
NODE_ID: node-3
TOPGUN_PORT: 8080
TOPGUN_CLUSTER_PORT: 9080
TOPGUN_PEERS: node-1:9080,node-2:9080
DATABASE_URL: postgres://${DB_USER:-topgun}:${DB_PASSWORD:-topgun_dev}@postgres:5432/${DB_NAME:-topgun}
profiles: ["cluster"]
depends_on:
postgres:
condition: service_healthy
networks:
- topgun
volumes:
postgres-data:
prometheus-data:
grafana-data:
topgun-data:
networks:
topgun:
driver: bridge