-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
145 lines (139 loc) · 3.47 KB
/
docker-compose.prod.yml
File metadata and controls
145 lines (139 loc) · 3.47 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
services:
# 1. 后端 API 服务 (FastAPI + Test Hub)
api:
build: .
image: devops-platform:latest
container_name: devops-api
restart: always
ports:
- "8000:8000"
volumes:
- ./persistence_data:/app/data
- /etc/localtime:/etc/localtime:ro
environment:
- TZ=Asia/Shanghai
env_file:
- .env
depends_on:
db:
condition: service_healthy
mq:
condition: service_healthy
healthcheck:
test: [ "CMD", "nc", "-z", "localhost", "8000" ]
interval: 10s
timeout: 5s
retries: 20
start_period: 60s
command: uvicorn devops_portal.main:app --host 0.0.0.0 --port 8000
logging: &logging
driver: "json-file"
options:
max-size: "100m"
max-file: "3"
# 2. 数据异步采集 Worker
worker:
image: devops-platform:latest
container_name: devops-worker
restart: always
volumes:
- ./persistence_data:/app/data
- /etc/localtime:/etc/localtime:ro
environment:
- TZ=Asia/Shanghai
env_file:
- .env
depends_on:
db:
condition: service_healthy
mq:
condition: service_healthy
command: python -m devops_collector.worker
logging: *logging
# 3. 任务调度器
scheduler:
image: devops-platform:latest
container_name: devops-scheduler
restart: always
environment:
- TZ=Asia/Shanghai
env_file:
- .env
volumes:
- /etc/localtime:/etc/localtime:ro
depends_on:
db:
condition: service_healthy
mq:
condition: service_healthy
command: python -m devops_collector.scheduler
logging: *logging
# 4. PostgreSQL 数据库
db:
image: postgres:15-alpine
container_name: devops-db
restart: always
environment:
- TZ=Asia/Shanghai
env_file:
- .env
volumes:
- postgres_data:/var/lib/postgresql/data
- /etc/localtime:/etc/localtime:ro
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 5s
timeout: 5s
retries: 5
logging: *logging
# 5. RabbitMQ 消息队列
mq:
image: rabbitmq:3-management-alpine
container_name: devops-mq
restart: always
ports:
- "5672:5672"
# 生产环境通常不需要暴露管理端口到公网,但这里保留供内部使用,或建议通过 ssh tunnel 访问
- "15672:15672"
volumes:
- rabbitmq_data:/var/lib/rabbitmq
- /etc/localtime:/etc/localtime:ro
environment:
- TZ=Asia/Shanghai
- RABBITMQ_DEFAULT_USER=${RABBITMQ_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASSWORD}
- RABBITMQ_VM_MEMORY_HIGH_WATERMARK_RELATIVE=0.7
healthcheck:
test: [ "CMD", "rabbitmq-diagnostics", "-q", "ping" ]
interval: 5s
timeout: 10s
retries: 60
start_period: 60s
logging: *logging
# 6. Decision Hub (Streamlit Dashboard)
dashboard:
image: devops-platform:latest
container_name: devops-dashboard
restart: always
ports:
- "8501:8501"
volumes:
- /etc/localtime:/etc/localtime:ro
environment:
- TZ=Asia/Shanghai
env_file:
- .env
depends_on:
db:
condition: service_healthy
healthcheck:
test: [ "CMD", "nc", "-z", "localhost", "8501" ]
interval: 10s
timeout: 10s
retries: 30
start_period: 120s
command: streamlit run dashboard/Home.py
logging: *logging
volumes:
postgres_data:
rabbitmq_data: