-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
165 lines (158 loc) · 3.85 KB
/
docker-compose.yml
File metadata and controls
165 lines (158 loc) · 3.85 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
services:
# 1. 后端 API 服务 (FastAPI + Test Hub)
api:
build:
context: .
args:
- PIP_INDEX_URL=http://192.168.5.64:8081/repository/group-pypi/simple
- PIP_TRUSTED_HOST=192.168.5.64
image: devops-platform:latest
container_name: devops-api
profiles: [ "core" ]
ports:
- "8000:8000"
volumes:
- .:/app
- /app/.venv
- ./persistence_data:/app/data
env_file:
- .env
depends_on:
db:
condition: service_healthy
mq:
condition: service_healthy
environment:
- RABBITMQ__HOST=mq
- RABBITMQ__USER=admin
- RABBITMQ__PASSWORD=admin123
healthcheck:
test: [ "CMD", "nc", "-z", "localhost", "8000" ]
interval: 10s
timeout: 5s
retries: 20
start_period: 60s
command: uv run uvicorn devops_portal.main:app --host 0.0.0.0 --port 8000
# 2. 数据异步采集 Worker (多实例竞争消费)
worker:
image: devops-platform:latest
profiles: [ "core" ]
volumes:
- .:/app
- /app/.venv
- ./persistence_data:/app/data
entrypoint: [ "uv", "run", "python", "-m", "devops_collector.worker" ]
env_file:
- .env
depends_on:
db:
condition: service_healthy
mq:
condition: service_healthy
environment:
- PYTHONPATH=/app
- RABBITMQ__HOST=mq
- RABBITMQ__USER=admin
- RABBITMQ__PASSWORD=admin123
restart: unless-stopped
deploy:
replicas: 2
# 3. 任务调度器
scheduler:
image: devops-platform:latest
container_name: devops-scheduler
profiles: [ "core" ]
volumes:
- .:/app
- /app/.venv
- ./persistence_data:/app/data
entrypoint: [ "uv", "run", "python", "-m", "devops_collector.scheduler" ]
env_file:
- .env
depends_on:
db:
condition: service_healthy
mq:
condition: service_healthy
environment:
- PYTHONPATH=/app
- RABBITMQ__HOST=mq
- RABBITMQ__USER=admin
- RABBITMQ__PASSWORD=admin123
# 4. PostgreSQL 数据库
db:
image: postgres:15-alpine
container_name: devops-db
profiles: [ "core" ]
env_file:
- .env
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ]
interval: 5s
timeout: 5s
retries: 20
# 5. RabbitMQ 消息队列
mq:
image: rabbitmq:3-management-alpine
container_name: devops-mq
profiles: [ "core" ]
environment:
- RABBITMQ_DEFAULT_USER=admin
- RABBITMQ_DEFAULT_PASS=admin123
- RABBITMQ_VM_MEMORY_HIGH_WATERMARK_RELATIVE=0.7
ports:
- "5672:5672"
- "15672:15672" # 管理后台
volumes:
- /var/lib/rabbitmq
healthcheck:
test: [ "CMD", "rabbitmq-diagnostics", "-q", "ping" ]
interval: 10s
timeout: 10s
retries: 60
# 6. DataHub CLI (独立采集容器)
# datahub-cli:
# build:
# context: ./datahub
# dockerfile: Dockerfile
# image: devops-platform-datahub:latest
# container_name: devops-datahub-cli
# # profiles:
# # - tools
# volumes:
# - .:/app
# env_file:
# - .env
# depends_on:
# db:
# condition: service_healthy
# 7. Decision Hub (Streamlit Dashboard)
dashboard:
image: devops-platform:latest
container_name: devops-dashboard
profiles: [ "dataops" ]
ports:
- "8501:8501"
volumes:
- .:/app
env_file:
- .env
depends_on:
db:
condition: service_healthy
environment:
- PYTHONPATH=/app
healthcheck:
test: [ "CMD", "nc", "-z", "localhost", "8501" ]
interval: 10s
timeout: 5s
retries: 10
start_period: 60s
command: streamlit run dashboard/Home.py
volumes:
postgres_data:
rabbitmq_data: