Repository navigation
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
82 lines (76 loc) · 2.28 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
82 lines (76 loc) · 2.28 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
# 開發設定(前後端熱重載)。使用方式:
# cp .env.example .env
# docker compose -f docker-compose.dev.yml up
# 前端(熱重載):http://localhost:5173 API 文件:http://localhost:8000/api/docs
name: scheduling-dev
services:
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.dev
ports:
- "5173:5173"
volumes:
- ./frontend:/app
- /app/node_modules # 保留容器內安裝的相依,不被掛載覆蓋
depends_on:
- api
api:
build:
context: ./backend
# dev:遷移後以 --reload 啟動,原始碼變更即時生效
entrypoint: ["bash", "-c", "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload"]
env_file: .env
environment:
# 開發時打開互動式 API 文件(http://localhost:8000/api/docs);正式部署預設關閉
API_DOCS_ENABLED: "true"
ports:
- "8000:8000"
volumes:
- ./backend:/app
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
worker:
build:
context: ./backend
# dev 用單一行程守兩條佇列:ops 在前(匯出/備份/寄信是秒級,先撈先做),default 在後。
# 正式環境拆成 worker + worker-ops 兩個容器,排課才不會堵住匯出(見 docker-compose.yml)。
# 這裡若只寫 ["worker"],dev 就沒有任何行程在守 ops——匯出、備份、寄信、定時任務全失效。
command: ["worker", "ops", "default"]
env_file: .env
volumes:
- ./backend:/app
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
postgres:
image: postgres:16-alpine
environment:
POSTGRES_USER: ${POSTGRES_USER:-scheduler}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-scheduler}
POSTGRES_DB: ${POSTGRES_DB:-scheduler}
ports:
- "5432:5432"
volumes:
- pgdata_dev:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-scheduler}"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
ports:
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
volumes:
pgdata_dev: