-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
354 lines (334 loc) · 7.7 KB
/
docker-compose.prod.yml
File metadata and controls
354 lines (334 loc) · 7.7 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
# Docker Compose for Production Environment
# Usage: docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
services:
# ===========================================
# 生产环境优化配置
# ===========================================
phone-gateway:
build:
target: production
deploy:
replicas: 2
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
volumes:
- ./logs/phone-gateway:/app/logs:rw
realtime-processor:
build:
target: production
deploy:
replicas: 3 # 核心服务,需要更多实例
resources:
limits:
cpus: '2.0'
memory: 1G
reservations:
cpus: '1.0'
memory: 512M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
conversation-engine:
build:
target: production
deploy:
replicas: 2
resources:
limits:
cpus: '1.5'
memory: 768M
reservations:
cpus: '0.75'
memory: 384M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
profile-analytics:
build:
target: production
deploy:
replicas: 2
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
user-management:
build:
target: production
deploy:
replicas: 2
resources:
limits:
cpus: '0.5'
memory: 256M
reservations:
cpus: '0.25'
memory: 128M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
smart-whitelist:
build:
target: production
deploy:
replicas: 2
resources:
limits:
cpus: '0.5'
memory: 256M
reservations:
cpus: '0.25'
memory: 128M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
configuration:
build:
target: production
deploy:
replicas: 1
resources:
limits:
cpus: '0.25'
memory: 128M
reservations:
cpus: '0.1'
memory: 64M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
storage:
build:
target: production
deploy:
replicas: 2
resources:
limits:
cpus: '0.5'
memory: 256M
reservations:
cpus: '0.25'
memory: 128M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
monitoring:
build:
target: production
deploy:
replicas: 1
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
environment:
- NODE_ENV=production
- LOG_LEVEL=info
command: npm start
# ===========================================
# 生产数据库配置
# ===========================================
postgres:
deploy:
replicas: 1
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '1.0'
memory: 1G
restart_policy:
condition: on-failure
delay: 10s
max_attempts: 5
environment:
- POSTGRES_DB=ai_ninja
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_INITDB_ARGS=--encoding=UTF8 --locale=C
command: >
postgres
-c shared_preload_libraries=pg_stat_statements
-c pg_stat_statements.max=10000
-c pg_stat_statements.track=all
-c max_connections=500
-c shared_buffers=512MB
-c effective_cache_size=2GB
-c work_mem=8MB
-c maintenance_work_mem=128MB
-c checkpoint_completion_target=0.9
-c wal_buffers=16MB
-c default_statistics_target=500
redis:
deploy:
replicas: 1
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.5'
memory: 256M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
command: >
redis-server
/usr/local/etc/redis/redis.conf
--maxmemory 256mb
--maxmemory-policy allkeys-lru
--save 900 1
--save 300 10
--save 60 10000
# ===========================================
# 生产环境负载均衡器
# ===========================================
nginx:
deploy:
replicas: 2
resources:
limits:
cpus: '0.5'
memory: 128M
reservations:
cpus: '0.25'
memory: 64M
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
ports:
- "80:80"
- "443:443"
# ===========================================
# 生产监控和日志收集
# ===========================================
# Filebeat for log shipping
filebeat:
image: docker.elastic.co/beats/filebeat:8.8.0
container_name: ai-ninja-filebeat
user: root
environment:
- ELASTICSEARCH_HOSTS=${ELASTICSEARCH_HOSTS:-http://elasticsearch:9200}
networks:
- ai-ninja-network
volumes:
- ./config/filebeat/filebeat.yml:/usr/share/filebeat/filebeat.yml:ro
- ./logs:/var/log/ai-ninja:ro
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
deploy:
replicas: 1
resources:
limits:
cpus: '0.25'
memory: 128M
# Prometheus Node Exporter
node-exporter:
image: prom/node-exporter:latest
container_name: ai-ninja-node-exporter
ports:
- "9100:9100"
networks:
- ai-ninja-network
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points=^/(sys|proc|dev|host|etc)($$|/)'
deploy:
replicas: 1
resources:
limits:
cpus: '0.1'
memory: 64M
# cAdvisor for container monitoring
cadvisor:
image: gcr.io/cadvisor/cadvisor:latest
container_name: ai-ninja-cadvisor
ports:
- "8083:8080"
networks:
- ai-ninja-network
volumes:
- /:/rootfs:ro
- /var/run:/var/run:ro
- /sys:/sys:ro
- /var/lib/docker/:/var/lib/docker:ro
- /dev/disk/:/dev/disk:ro
privileged: true
devices:
- /dev/kmsg
deploy:
replicas: 1
resources:
limits:
cpus: '0.3'
memory: 256M