Repository navigation
Expand file tree
/
Copy pathdocker-compose.prod-dev.yml
More file actions
383 lines (369 loc) · 10.5 KB
/
Copy pathdocker-compose.prod-dev.yml
File metadata and controls
383 lines (369 loc) · 10.5 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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# 生产环境开发模式配置 - 用于在生产服务器上调试
# 使用方式: docker compose -f docker-compose.prod-dev.yml up -d
#
# 此配置支持:
# - 源码挂载,支持热重载
# - 调试端口暴露
# - DEBUG 日志级别
#
# 注意: 仅在需要调试时使用,调试完成后应切换回生产模式
services:
# ==================== 核心服务 ====================
# API 服务 - 开发模式,支持热重载
api:
image: pisuan-api:0.3.prod
container_name: pisuan-api-dev
working_dir: /app
volumes:
# 源码挂载 - 支持热重载
- ./server:/app/server
- ./src:/app/src
# 数据持久化
- ${DATA_DIR:-./data}/saves:/app/saves
- ${DATA_DIR:-./data}/logs:/app/logs
- ${MODEL_DIR:-./models}:/models
# 测试和脚本(可选)
- ./test:/app/test
- ./scripts:/app/scripts
ports:
# 暴露 API 端口用于调试
- "${API_PORT:-5050}:5050"
networks:
- pisuan-network
env_file:
- .env.prod
environment:
- TZ=Asia/Shanghai
- HOST_IP=${HOST_IP:-}
- NEO4J_URI=bolt://graph:7687
- NEO4J_USERNAME=${NEO4J_USERNAME:-neo4j}
- NEO4J_PASSWORD=${NEO4J_PASSWORD}
- MILVUS_URI=http://milvus:19530
- MILVUS_TOKEN=${MILVUS_TOKEN:-}
- MINERU_OCR_URI=http://mineru:30000
- PADDLEX_URI=http://paddlex:8080
- MINIO_URI=http://milvus-minio:9000
- MODEL_DIR_IN_DOCKER=/models
- RUNNING_IN_DOCKER=true
- ONLYOFFICE_API_BASE_URL=http://pisuan-api-dev:5050
- ONLYOFFICE_JWT_SECRET=${ONLYOFFICE_JWT_SECRET}
- ONLYOFFICE_JWT_ENABLED=${ONLYOFFICE_JWT_ENABLED:-true}
- REDIS_URL=redis://redis:6379/0
# 开发模式日志级别
- LOG_LEVEL=${LOG_LEVEL:-DEBUG}
- NO_PROXY=localhost,127.0.0.1,milvus,graph,milvus-minio,milvus-etcd,etcd,minio,mineru,paddlex,redis
- no_proxy=localhost,127.0.0.1,milvus,graph,milvus-minio,milvus-etcd,etcd,minio,mineru,paddlex,redis
# 开发模式: 使用 uvicorn --reload
command: uv run --no-dev uvicorn server.main:app --host 0.0.0.0 --port 5050 --reload
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:5050/api/system/health || exit 1"]
interval: 30s
timeout: 15s
retries: 8
start_period: 180s
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
depends_on:
milvus:
condition: service_healthy
graph:
condition: service_healthy
redis:
condition: service_healthy
# Web 前端服务 - 可选择使用 Nginx 或 Vite dev server
web:
image: pisuan-web:0.3.prod
container_name: pisuan-web-dev
ports:
- "${WEB_PORT:-80}:80"
volumes:
# Nginx 配置
- ${CONFIG_DIR:-./config}/nginx/nginx.prod.conf:/etc/nginx/conf.d/default.conf:ro
networks:
- pisuan-network
environment:
- TZ=Asia/Shanghai
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
depends_on:
api:
condition: service_healthy
# ==================== 数据存储服务 ====================
# Neo4j 图数据库 - 暴露端口用于调试
graph:
image: neo4j:5.26
container_name: pisuan-neo4j-dev
ports:
# 暴露端口用于调试
- "${NEO4J_HTTP_PORT:-7474}:7474"
- "${NEO4J_BOLT_PORT:-7687}:7687"
volumes:
- ${DATA_DIR:-./data}/neo4j/data:/data
- ${DATA_DIR:-./data}/neo4j/logs:/var/lib/neo4j/logs
networks:
- pisuan-network
environment:
- TZ=Asia/Shanghai
- NEO4J_AUTH=${NEO4J_USERNAME:-neo4j}/${NEO4J_PASSWORD}
- NEO4J_server_bolt_listen__address=0.0.0.0:7687
- NEO4J_server_http_listen__address=0.0.0.0:7474
- ENTITY_EMBEDDING=true
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:7474 || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
# Milvus 向量数据库依赖 - Etcd
etcd:
image: quay.io/coreos/etcd:v3.5.5
container_name: pisuan-etcd-dev
environment:
- TZ=Asia/Shanghai
- ETCD_AUTO_COMPACTION_MODE=revision
- ETCD_AUTO_COMPACTION_RETENTION=1000
- ETCD_QUOTA_BACKEND_BYTES=4294967296
- ETCD_SNAPSHOT_COUNT=50000
volumes:
- ${DATA_DIR:-./data}/milvus/etcd:/etcd
command: etcd -advertise-client-urls=http://etcd:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
networks:
- pisuan-network
restart: unless-stopped
healthcheck:
test: ["CMD", "etcdctl", "endpoint", "health"]
interval: 60s
timeout: 30s
retries: 5
start_period: 30s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "3"
# Milvus 向量数据库依赖 - MinIO
minio:
image: minio/minio:RELEASE.2023-03-20T20-16-18Z
container_name: pisuan-minio-dev
ports:
# 暴露端口用于调试
- "${MINIO_API_PORT:-9000}:9000"
- "${MINIO_CONSOLE_PORT:-9001}:9001"
environment:
- TZ=Asia/Shanghai
- MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-minioadmin}
- MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-minioadmin}
volumes:
- ${DATA_DIR:-./data}/milvus/minio:/minio_data
- ${DATA_DIR:-./data}/milvus/minio_config:/root/.minio
command: minio server /minio_data --address 0.0.0.0:9000 --console-address 0.0.0.0:9001
networks:
- pisuan-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 60s
timeout: 30s
retries: 5
start_period: 30s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "3"
# Milvus 向量数据库
milvus:
image: milvusdb/milvus:v2.5.6
container_name: pisuan-milvus-dev
command: ["milvus", "run", "standalone"]
security_opt:
- seccomp:unconfined
ports:
# 暴露端口用于调试
- "${MILVUS_PORT:-19530}:19530"
- "${MILVUS_HEALTH_PORT:-9091}:9091"
environment:
- TZ=Asia/Shanghai
- ETCD_ENDPOINTS=etcd:2379
- MINIO_ADDRESS=minio:9000
- MILVUS_LOG_LEVEL=info
volumes:
- ${DATA_DIR:-./data}/milvus/milvus:/var/lib/milvus
- ${DATA_DIR:-./data}/milvus/logs:/var/lib/milvus/logs
networks:
- pisuan-network
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
interval: 60s
timeout: 30s
retries: 5
start_period: 120s
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
depends_on:
etcd:
condition: service_healthy
minio:
condition: service_healthy
# Redis 缓存服务
redis:
image: redis:7-alpine
container_name: pisuan-redis-dev
ports:
# 暴露端口用于调试
- "${REDIS_PORT:-6379}:6379"
volumes:
- ${DATA_DIR:-./data}/redis:/data
command: redis-server --appendonly yes --maxmemory ${REDIS_MAXMEMORY:-256mb} --maxmemory-policy allkeys-lru
networks:
- pisuan-network
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
logging:
driver: "json-file"
options:
max-size: "50m"
max-file: "3"
# ==================== 可选服务 (GPU) ====================
# OnlyOffice 文档服务
onlyoffice:
image: onlyoffice/documentserver:latest
container_name: pisuan-onlyoffice-dev
profiles:
- office
ports:
- "${ONLYOFFICE_PORT:-8175}:80"
volumes:
- ${DATA_DIR:-./data}/onlyoffice/logs:/var/log/onlyoffice
- ${DATA_DIR:-./data}/onlyoffice/data:/var/www/onlyoffice/Data
networks:
- pisuan-network
environment:
- TZ=Asia/Shanghai
- ALLOW_PRIVATE_IP_ADDRESSES=true
- JWT_ENABLED=${ONLYOFFICE_JWT_ENABLED:-true}
- JWT_SECRET=${ONLYOFFICE_JWT_SECRET}
- JWT_HEADER=Authorization
command: >
sh -c "
echo '{}' > /var/www/onlyoffice/documentserver/web-apps/vendor/socketio/socket.io.min.js.map 2>/dev/null || true;
/app/ds/run-document-server.sh
"
restart: unless-stopped
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
depends_on:
api:
condition: service_healthy
# MinerU OCR 服务 (需要 GPU)
mineru:
image: mineru-vllm:latest
container_name: pisuan-mineru-dev
profiles:
- gpu
ports:
- "${MINERU_PORT:-30000}:30000"
env_file:
- .env.prod
environment:
- TZ=Asia/Shanghai
- MINERU_MODEL_SOURCE=local
entrypoint: mineru-vllm-server
command:
- --host
- "0.0.0.0"
- --port
- "30000"
ulimits:
memlock: -1
stack: 67108864
ipc: host
networks:
- pisuan-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:30000/health || exit 1"]
interval: 60s
timeout: 30s
retries: 5
start_period: 120s
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ["0"]
capabilities: [gpu]
# PaddleX OCR 服务 (需要 GPU)
paddlex:
image: paddlex:latest
container_name: pisuan-paddlex-dev
profiles:
- gpu
ports:
- "${PADDLEX_PORT:-8080}:8080"
volumes:
- ${DATA_DIR:-./data}/paddlex:/paddlex
networks:
- pisuan-network
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/health || exit 1"]
interval: 60s
timeout: 30s
retries: 5
start_period: 120s
logging:
driver: "json-file"
options:
max-size: "100m"
max-file: "5"
deploy:
resources:
reservations:
devices:
- driver: nvidia
device_ids: ["0"]
capabilities: [gpu]
# ==================== 网络配置 ====================
networks:
pisuan-network:
driver: bridge
name: pisuan-dev-network