-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
277 lines (256 loc) · 7.6 KB
/
docker-compose.yml
File metadata and controls
277 lines (256 loc) · 7.6 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
# 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:
build:
context: .
dockerfile: deploy/Dockerfile.server
ports:
- "${SERVER_PORT:-8080}:8080"
- "${CLUSTER_PORT:-9080}:9080"
environment:
NODE_ENV: production
TOPGUN_PORT: 8080
TOPGUN_CLUSTER_PORT: 9080
DATABASE_URL: postgres://${DB_USER:-topgun}:${DB_PASSWORD:-topgun_dev}@postgres:5432/${DB_NAME:-topgun}
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: 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"]
depends_on:
- server
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 (Zero-Touch Automated Setup)
# Usage: docker compose --profile auto-setup up
# This profile demonstrates automatic server configuration via env vars
# ============================================================================
server-auto:
build:
context: .
dockerfile: deploy/Dockerfile.server
ports:
- "${SERVER_PORT:-8080}:8080"
- "${METRICS_PORT:-9090}:9090"
environment:
NODE_ENV: production
# Zero-Touch Setup Configuration
TOPGUN_AUTO_SETUP: "true"
TOPGUN_STORAGE_TYPE: postgres
TOPGUN_DEPLOYMENT_MODE: standalone
TOPGUN_PORT: 8080
TOPGUN_METRICS_PORT: 9090
DATABASE_URL: postgres://${DB_USER:-topgun}:${DB_PASSWORD:-topgun_dev}@postgres:5432/${DB_NAME:-topgun}
# Admin credentials from Docker secrets
TOPGUN_ADMIN_USER: admin
TOPGUN_ADMIN_PASSWORD_FILE: /run/secrets/admin_password
TOPGUN_ADMIN_EMAIL: admin@example.com
# Optional integrations
TOPGUN_MCP_ENABLED: "false"
TOPGUN_VECTOR_ENABLED: "false"
secrets:
- admin_password
profiles: ["auto-setup"]
depends_on:
postgres:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:9090/api/status"]
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:
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:
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:
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:
secrets:
admin_password:
file: ./secrets/admin_password.txt
networks:
topgun:
driver: bridge