添加docker部署方式,优化目前项目结构,更新了readme文件
This commit is contained in:
@@ -2,18 +2,31 @@ version: '3.8'
|
||||
|
||||
services:
|
||||
tsp-assistant:
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: tsp_assistant
|
||||
ports:
|
||||
- "5000:5000"
|
||||
- "8765:8765" # WebSocket端口
|
||||
environment:
|
||||
- PYTHONPATH=/app
|
||||
- DATABASE_URL=sqlite:///tsp_assistant.db
|
||||
- DATABASE_URL=mysql+pymysql://tsp_user:tsp_password@mysql:3306/tsp_assistant?charset=utf8mb4
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
- LOG_LEVEL=INFO
|
||||
- TZ=Asia/Shanghai
|
||||
volumes:
|
||||
- ./data:/app/data
|
||||
- ./logs:/app/logs
|
||||
- ./backups:/app/backups
|
||||
- ./uploads:/app/uploads
|
||||
- ./config:/app/config
|
||||
- tsp_db:/app
|
||||
depends_on:
|
||||
mysql:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:5000/api/health"]
|
||||
@@ -21,8 +34,10 @@ services:
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
networks:
|
||||
- tsp_network
|
||||
|
||||
# MySQL数据库服务(可选)
|
||||
# MySQL数据库服务
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
container_name: tsp_mysql
|
||||
@@ -31,15 +46,44 @@ services:
|
||||
MYSQL_DATABASE: tsp_assistant
|
||||
MYSQL_USER: tsp_user
|
||||
MYSQL_PASSWORD: tsp_password
|
||||
MYSQL_CHARACTER_SET_SERVER: utf8mb4
|
||||
MYSQL_COLLATION_SERVER: utf8mb4_unicode_ci
|
||||
ports:
|
||||
- "3306:3306"
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql
|
||||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||
restart: unless-stopped
|
||||
command: --default-authentication-plugin=mysql_native_password
|
||||
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot123456"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
networks:
|
||||
- tsp_network
|
||||
|
||||
# Nginx反向代理(可选)
|
||||
# Redis缓存服务
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: tsp_redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
restart: unless-stopped
|
||||
command: redis-server --appendonly yes --requirepass redis123456
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "--raw", "incr", "ping"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
networks:
|
||||
- tsp_network
|
||||
|
||||
# Nginx反向代理
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
container_name: tsp_nginx
|
||||
@@ -49,10 +93,61 @@ services:
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf
|
||||
- ./ssl:/etc/nginx/ssl
|
||||
- ./logs/nginx:/var/log/nginx
|
||||
depends_on:
|
||||
- tsp-assistant
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 30s
|
||||
networks:
|
||||
- tsp_network
|
||||
|
||||
# 监控服务
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
container_name: tsp_prometheus
|
||||
ports:
|
||||
- "9090:9090"
|
||||
volumes:
|
||||
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data:/prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
- '--storage.tsdb.path=/prometheus'
|
||||
- '--web.console.libraries=/etc/prometheus/console_libraries'
|
||||
- '--web.console.templates=/etc/prometheus/consoles'
|
||||
- '--storage.tsdb.retention.time=200h'
|
||||
- '--web.enable-lifecycle'
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- tsp_network
|
||||
|
||||
# Grafana仪表板
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
container_name: tsp_grafana
|
||||
ports:
|
||||
- "3000:3000"
|
||||
environment:
|
||||
- GF_SECURITY_ADMIN_PASSWORD=admin123456
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./monitoring/grafana/provisioning:/etc/grafana/provisioning
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- tsp_network
|
||||
|
||||
volumes:
|
||||
tsp_db:
|
||||
mysql_data:
|
||||
redis_data:
|
||||
prometheus_data:
|
||||
grafana_data:
|
||||
|
||||
networks:
|
||||
tsp_network:
|
||||
driver: bridge
|
||||
|
||||
Reference in New Issue
Block a user