-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
212 lines (197 loc) · 6.65 KB
/
Copy pathdocker-compose.yml
File metadata and controls
212 lines (197 loc) · 6.65 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
# ============================================================================
# 「鉴微」基础编排(base)—— 同时适用 Windows Docker Desktop 与 阿里云 ECS
# 用法见 scripts/start.ps1(Windows)/ scripts/start.sh(ECS)
# dev: docker compose -f docker-compose.yml -f docker-compose.dev.yml up -d
# master: docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# 设计:① 数据全用命名卷(跨平台)② 镜像锁 linux/amd64 ③ 全服务 healthcheck
# ④ 前端镜像自带 nginx 托管 dist,Caddy 反代(免绑定挂载,Windows/ECS 通用)
# ============================================================================
name: jianwei
x-backend-build: &backend-build
context: ./backend
dockerfile: Dockerfile
x-logging: &default-logging
driver: json-file
options:
max-size: "10m"
max-file: "3"
services:
# ---------------- 反向代理 / 网关 ----------------
caddy:
image: caddy:2
platform: linux/amd64
restart: unless-stopped
ports:
- "${HTTP_PORT:-80}:80"
- "${HTTPS_PORT:-443}:443"
environment:
DOMAIN: ${DOMAIN:-localhost}
volumes:
- ./deploy/Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
depends_on:
- api
- frontend
networks: [web, internal]
logging: *default-logging
# ---------------- 前端(生产:nginx 托管 Vue 构建产物)----------------
frontend:
image: ${REGISTRY:-jianwei}/frontend:${TAG:-latest}
platform: linux/amd64
build:
context: ./frontend
dockerfile: Dockerfile
target: prod
restart: unless-stopped
expose: ["80"]
networks: [web]
logging: *default-logging
# ---------------- API 层(FastAPI · REST + SSE)----------------
api:
image: ${REGISTRY:-jianwei}/api:${TAG:-latest}
platform: linux/amd64
build: *backend-build
restart: unless-stopped
env_file: .env
expose: ["8000"]
depends_on:
postgres: { condition: service_healthy }
redis: { condition: service_healthy }
qdrant: { condition: service_started }
minio: { condition: service_started }
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8000/api/health',timeout=3).status==200 else 1)"]
interval: 30s
timeout: 5s
retries: 5
start_period: 40s
networks: [web, internal]
logging: *default-logging
# ---------------- 默认 Worker(GitHub 解析 / 站点重构 / 入库)----------------
worker-default:
image: ${REGISTRY:-jianwei}/api:${TAG:-latest}
platform: linux/amd64
build: *backend-build
restart: unless-stopped
command: celery -A app.worker.celery_app worker -Q default -c ${WORKER_DEFAULT_CONCURRENCY:-4} -l ${LOG_LEVEL:-INFO} -n default@%h
env_file: .env
depends_on:
redis: { condition: service_healthy }
postgres: { condition: service_healthy }
qdrant: { condition: service_started }
healthcheck:
test: ["CMD", "celery", "-A", "app.worker.celery_app", "inspect", "ping", "-d", "default@$$HOSTNAME"]
interval: 60s
timeout: 10s
retries: 3
start_period: 30s
networks: [internal]
logging: *default-logging
# ---------------- 爬虫 Worker(含 Playwright 浏览器,独立队列)----------------
worker-crawler:
image: ${REGISTRY:-jianwei}/crawler:${TAG:-latest}
platform: linux/amd64
build:
context: ./backend
dockerfile: Dockerfile.crawler
restart: unless-stopped
command: celery -A app.worker.celery_app worker -Q crawler -c ${WORKER_CRAWLER_CONCURRENCY:-2} -l ${LOG_LEVEL:-INFO} -n crawler@%h
env_file: .env
depends_on:
redis: { condition: service_healthy }
minio: { condition: service_started }
networks: [internal]
logging: *default-logging
# ---------------- Celery Beat(6h 资讯调度,单实例)----------------
beat:
image: ${REGISTRY:-jianwei}/api:${TAG:-latest}
platform: linux/amd64
build: *backend-build
restart: unless-stopped
command: celery -A app.worker.celery_app beat -l ${LOG_LEVEL:-INFO} --schedule /tmp/celerybeat-schedule
env_file: .env
depends_on:
redis: { condition: service_healthy }
networks: [internal]
logging: *default-logging
# ---------------- PostgreSQL ----------------
postgres:
image: postgres:16
platform: linux/amd64
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-jianwei}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-jianwei}
POSTGRES_DB: ${POSTGRES_DB:-jianwei}
volumes:
- pg_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-jianwei} -d ${POSTGRES_DB:-jianwei}"]
interval: 10s
timeout: 5s
retries: 5
networks: [internal]
logging: *default-logging
# ---------------- Redis(缓存 / broker / 资讯环形 50 条)----------------
redis:
image: redis:7
platform: linux/amd64
restart: unless-stopped
command: ["redis-server", "--appendonly", "yes", "--maxmemory-policy", "noeviction"]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks: [internal]
logging: *default-logging
# ---------------- Qdrant 向量库 ----------------
qdrant:
image: qdrant/qdrant:latest
platform: linux/amd64
restart: unless-stopped
volumes:
- qdrant_data:/qdrant/storage
networks: [internal]
logging: *default-logging
# ---------------- MinIO 对象存储(生产可换 OSS)----------------
minio:
image: minio/minio:latest
platform: linux/amd64
restart: unless-stopped
command: server /data --console-address ":9001"
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin123}
volumes:
- minio_data:/data
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 15s
timeout: 5s
retries: 5
networks: [internal]
logging: *default-logging
# ---------------- 可选:自托管 Embedding/Rerank(profile: full)----------------
embedding:
image: michaelf34/infinity:latest
platform: linux/amd64
restart: unless-stopped
command: v2 --model-id BAAI/bge-m3 --model-id BAAI/bge-reranker-v2-m3 --port 7997
profiles: ["full"]
expose: ["7997"]
networks: [internal]
logging: *default-logging
volumes:
pg_data: {}
redis_data: {}
qdrant_data: {}
minio_data: {}
caddy_data: {}
caddy_config: {}
networks:
web: {}
internal: {}