forked from gongxings/ai-creator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
123 lines (115 loc) · 2.93 KB
/
docker-compose.yml
File metadata and controls
123 lines (115 loc) · 2.93 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
version: '3.8'
services:
# MySQL数据库
mysql:
image: mysql:8.0
container_name: ai-creator-mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root123456}
MYSQL_DATABASE: ${MYSQL_DATABASE:-ai_creator}
MYSQL_USER: ${MYSQL_USER:-ai_creator}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-ai_creator123}
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password
networks:
- ai-creator-network
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 10s
timeout: 5s
retries: 5
# Redis缓存
redis:
image: redis:7-alpine
container_name: ai-creator-redis
ports:
- "6379:6379"
volumes:
- redis_data:/data
networks:
- ai-creator-network
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
# 后端API服务
backend:
build:
context: ./backend
dockerfile: Dockerfile
container_name: ai-creator-backend
environment:
- DATABASE_URL=mysql+pymysql://${MYSQL_USER:-ai_creator}:${MYSQL_PASSWORD:-ai_creator123}@mysql:3306/${MYSQL_DATABASE:-ai_creator}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-in-production}
ports:
- "8000:8000"
volumes:
- ./backend:/app
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- ai-creator-network
command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
# Celery Worker
celery-worker:
build:
context: ./backend
dockerfile: Dockerfile
container_name: ai-creator-celery-worker
environment:
- DATABASE_URL=mysql+pymysql://${MYSQL_USER:-ai_creator}:${MYSQL_PASSWORD:-ai_creator123}@mysql:3306/${MYSQL_DATABASE:-ai_creator}
- REDIS_URL=redis://redis:6379/0
- SECRET_KEY=${SECRET_KEY:-your-secret-key-change-in-production}
volumes:
- ./backend:/app
depends_on:
- redis
- mysql
networks:
- ai-creator-network
command: celery -A app.core.celery_app worker --loglevel=info
# 前端服务
frontend:
build:
context: ./frontend
dockerfile: Dockerfile
container_name: ai-creator-frontend
ports:
- "3000:3000"
volumes:
- ./frontend:/app
- /app/node_modules
depends_on:
- backend
networks:
- ai-creator-network
command: npm run dev
# Nginx反向代理
nginx:
image: nginx:alpine
container_name: ai-creator-nginx
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/ssl:/etc/nginx/ssl
depends_on:
- backend
- frontend
networks:
- ai-creator-network
volumes:
mysql_data:
redis_data:
networks:
ai-creator-network:
driver: bridge