-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
57 lines (52 loc) · 1.64 KB
/
docker-compose.yml
File metadata and controls
57 lines (52 loc) · 1.64 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
version: '3.8'
services:
# 1. 訊息佇列 (Message Broker)
redis:
image: redis:alpine
ports:
- "6379:6379"
# 2. 前端 API (接收請求, 不做重運算)
# SECURITY: Port 8000 removed from host exposure. Only accessible internally.
api:
build: ./api
# ports:
# - "8000:8000" <-- REMOVED for security
volumes:
- shared_data:/app/data # 掛載共享儲存區
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
depends_on:
- redis
# 3. 後端 Worker (執行重運算)
worker:
build: ./worker
volumes:
- shared_data:/app/data # 掛載共享儲存區
- huggingface_cache:/root/.cache/huggingface # 快取模型,避免重啟重複下載
environment:
- CELERY_BROKER_URL=redis://redis:6379/0
- CELERY_RESULT_BACKEND=redis://redis:6379/0
# 強制設定 worker 內使用 CPU,避免嘗試呼叫不存在的 GPU 驅動
- CUDA_VISIBLE_DEVICES=""
# Google AI API Key (Text-to-Image 功能)
# 支援 GEMINI_API_KEY 或 GOOGLE_API_KEY
- GEMINI_API_KEY=${GEMINI_API_KEY}
- GOOGLE_API_KEY=${GOOGLE_API_KEY}
depends_on:
- redis
# 這裡可以透過 scale 擴展 worker 數量,例如: docker-compose up --scale worker=3
command: celery -A tasks worker --loglevel=info --concurrency=1
# 4. 前端介面 (Nuxt 3 BFF)
# SECURITY: This is the ONLY entry point for the user.
frontend:
build: ./frontend
ports:
- "3000:3000"
environment:
- NUXT_API_URL=http://api:8000
depends_on:
- api
volumes:
shared_data:
huggingface_cache: