-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
96 lines (90 loc) · 2.6 KB
/
Copy pathdocker-compose.yml
File metadata and controls
96 lines (90 loc) · 2.6 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
version: '3.8'
services:
# Bandix Monitor 应用服务
bandix-monitor:
build:
context: .
dockerfile: Dockerfile
container_name: bandix-monitor
restart: unless-stopped
ports:
- "5000:5000"
environment:
- FLASK_ENV=production
- API_HOST=0.0.0.0
- API_PORT=5000
- DEBUG=false
- SECRET_KEY=${SECRET_KEY:-change-this-secret-key-in-production}
# MySQL 连接(如果使用外部 MySQL,取消注释并修改)
# - MYSQL_HOST=mysql
# - MYSQL_PORT=3306
# - MYSQL_USER=hanbo
# - MYSQL_PASSWORD=${MYSQL_PASSWORD}
# - MYSQL_DATABASE=bandix_monitor
volumes:
# 配置文件(可选,用于覆盖容器内配置)
- ./app/config/bandix_config.ini:/app/app/config/bandix_config.ini:ro
# 数据持久化
- ./data/instance:/app/instance
- ./data/logs:/app/logs
- ./data/backups:/app/backups
- ./data/reports:/app/reports
depends_on:
mysql:
condition: service_healthy
networks:
- bandix-network
healthcheck:
test: ["CMD", "python", "-c", "import requests; requests.get('http://localhost:5000/health', timeout=5)"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# MySQL 数据库服务(可选,如果使用外部 MySQL 可以删除此服务)
mysql:
image: mysql:8.0
container_name: bandix-mysql
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-root123456}
- MYSQL_DATABASE=bandix_monitor
- MYSQL_USER=hanbo
- MYSQL_PASSWORD=${MYSQL_PASSWORD:-@HanBo123}
volumes:
- mysql_data:/var/lib/mysql
- ./docker/mysql/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
ports:
- "3306:3306"
networks:
- bandix-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=mysql_native_password
# Nginx 反向代理(可选)
nginx:
image: nginx:alpine
container_name: bandix-nginx
restart: unless-stopped
ports:
- "80:80"
- "443:443"
volumes:
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- ./docker/nginx/conf.d:/etc/nginx/conf.d:ro
depends_on:
- bandix-monitor
networks:
- bandix-network
volumes:
mysql_data:
driver: local
networks:
bandix-network:
driver: bridge