Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
155 lines (150 loc) · 4.3 KB
/
Copy pathdocker-compose.yml
File metadata and controls
155 lines (150 loc) · 4.3 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
# PaperMind Docker Compose - 分离部署配置
# @author Color2333
#
# 端口规划:
# - 前端:3002
# - 后端:8002
#
# 使用方法:
# 1. cp .env.example .env && 编辑 .env 填入 API Key
# 2. docker compose up -d --build
# 3. 访问 http://localhost:3002
services:
# ==========================================
# 后端服务 (FastAPI)
# ==========================================
backend:
build:
context: .
dockerfile: Dockerfile.backend
container_name: papermind-backend
ports:
- "8002:8000" # 映射到 8002(避免 8001 冲突)
volumes:
- pm_data:/app/data
- pm_logs:/app/logs
- pm_pip_cache:/.pip-cache
env_file:
- ./.env
environment:
- APP_ENV=production
- API_HOST=0.0.0.0
- API_PORT=8000
- SITE_URL=https://pm.vibingu.cn
- CORS_ALLOW_ORIGINS=http://localhost:3002,http://127.0.0.1:3002,https://pm.vibingu.cn
- DEMO_MODE=false
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
# DATABASE_URL=sqlite://... 时 backend 不实际连 postgres,但 compose
# 仍会拉起 postgres 容器,无副作用;切到 PG 后自动等待 ready
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:8000/health"]
interval: 30s
timeout: 5s
start_period: 40s
retries: 3
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# ==========================================
# Worker 服务 (定时任务 + 闲时处理)
# ==========================================
worker:
build:
context: .
dockerfile: Dockerfile.backend
container_name: papermind-worker
command: python -m apps.worker.main
volumes:
- pm_data:/app/data
- pm_logs:/app/logs
- pm_pip_cache:/.pip-cache
env_file:
- ./.env
environment:
- APP_ENV=production
- SITE_URL=https://pm.vibingu.cn
restart: unless-stopped
depends_on:
backend:
condition: service_started
postgres:
condition: service_healthy
# worker 共用 Dockerfile.backend(含 HEALTHCHECK curl 8000/health),但 worker
# 不跑 uvicorn,继承的 healthcheck 会误判 unhealthy。显式禁用 worker healthcheck。
healthcheck:
test: ["NONE"]
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# ==========================================
# 数据库服务 (PostgreSQL + pgvector)
# ==========================================
# 镜像带 pgvector 扩展(即使当前不用 ANN 也已就绪)。
# DATABASE_URL=sqlite://... 时 backend/worker 不会实际连接,但容器会启动占位;
# 切到 postgresql+psycopg2://... 后即自动使用。
postgres:
image: pgvector/pgvector:pg16
container_name: papermind-postgres
restart: unless-stopped
environment:
POSTGRES_DB: papermind
POSTGRES_USER: papermind
POSTGRES_PASSWORD: papermind
ports:
- "127.0.0.1:5432:5432" # 只对宿主本地暴露,外部不直连
volumes:
- papermind_pgdata:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U papermind -d papermind"]
interval: 10s
timeout: 5s
retries: 5
# ==========================================
# 前端服务 (Nginx 托管静态文件)
# ==========================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: papermind-frontend
ports:
- "3002:80" # 映射到 3002(避免 3001 冲突)
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:80"]
interval: 30s
timeout: 5s
start_period: 10s
retries: 3
deploy:
resources:
limits:
cpus: '0.5'
memory: 256M
reservations:
cpus: '0.1'
memory: 64M
# ==========================================
# 数据卷定义(持久化存储)
# ==========================================
volumes:
pm_data:
name: papermind_data
pm_logs:
name: papermind_logs
pm_pip_cache:
papermind_pgdata:
name: papermind_pgdata