-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
122 lines (115 loc) · 3.1 KB
/
docker-compose.yml
File metadata and controls
122 lines (115 loc) · 3.1 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
# GoldMind - 完整部署配置
# 一键启动:前端 + 后端 + 数据库
version: '3.8'
services:
# ============================================
# MySQL 数据库服务
# ============================================
mysql:
image: mysql:8.0
container_name: goldmind_mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-goldmind123}
MYSQL_DATABASE: gold_analysis
MYSQL_CHARSET: utf8mb4
MYSQL_COLLATION: utf8mb4_unicode_ci
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
- ./backend/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
networks:
- goldmind_network
# ============================================
# FastAPI 后端服务
# ============================================
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: goldmind_backend
restart: unless-stopped
depends_on:
mysql:
condition: service_healthy
env_file:
- ./backend/.env
environment:
# 数据库配置(覆盖.env中的配置)
- DATABASE_URL=mysql+pymysql://root:${MYSQL_ROOT_PASSWORD:-goldmind123}@mysql:3306/gold_analysis
- DB_HOST=mysql
- DB_PORT=3306
- DB_USER=root
- DB_PASSWORD=${MYSQL_ROOT_PASSWORD:-goldmind123}
- DB_NAME=gold_analysis
# AI API 密钥
- ZHIPU_API_KEY=${ZHIPU_API_KEY}
- DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY}
# 应用配置
- DEBUG=${DEBUG:-false}
- LOG_LEVEL=${LOG_LEVEL:-INFO}
ports:
- "8000:8000"
volumes:
- backend_cache:/app/cache
- backend_logs:/app/logs
networks:
- goldmind_network
# ============================================
# React 前端服务 (Nginx)
# ============================================
frontend:
build:
context: ./app
dockerfile: Dockerfile
container_name: goldmind_frontend
restart: unless-stopped
depends_on:
- backend
environment:
- VITE_API_URL=http://backend:8000
ports:
- "80:80"
- "443:443"
networks:
- goldmind_network
# ============================================
# Nginx 反向代理 (可选,用于生产环境)
# ============================================
# nginx:
# image: nginx:alpine
# container_name: goldmind_nginx
# restart: unless-stopped
# ports:
# - "80:80"
# - "443:443"
# volumes:
# - ./nginx.conf:/etc/nginx/nginx.conf
# - ./ssl:/etc/nginx/ssl
# depends_on:
# - frontend
# - backend
# networks:
# - goldmind_network
# ============================================
# 数据卷定义
# ============================================
volumes:
mysql_data:
driver: local
backend_cache:
driver: local
backend_logs:
driver: local
# ============================================
# 网络定义
# ============================================
networks:
goldmind_network:
driver: bridge