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: