-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
89 lines (83 loc) · 2.13 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
89 lines (83 loc) · 2.13 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
version: '3.8'
# 简化的开发环境 Docker Compose 配置
# 只启动核心服务:MySQL + Redis + API
# 使用方法: docker-compose -f docker-compose.dev.yml up -d
services:
# MySQL数据库
mysql:
image: mysql:8.0
container_name: volctrain-mysql-dev
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: volctraindb
MYSQL_USER: volctrain_app
MYSQL_PASSWORD: Abc@1234
ports:
- "3306:3306"
volumes:
- mysql_dev_data:/var/lib/mysql
- ./backend/sql:/docker-entrypoint-initdb.d:ro
networks:
- volctrain-dev
restart: unless-stopped
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-time-zone='+08:00'
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot"]
interval: 30s
timeout: 10s
retries: 5
# Redis缓存
redis:
image: redis:7-alpine
container_name: volctrain-redis-dev
ports:
- "6379:6379"
volumes:
- redis_dev_data:/data
networks:
- volctrain-dev
restart: unless-stopped
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
# 后端API服务
backend-api:
build:
context: ./backend
dockerfile: Dockerfile
container_name: volctrain-api-dev
environment:
# 部署环境
DEPLOY_ENV: development
# 数据库配置(覆盖配置文件中的默认值)
DB_HOST: mysql
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: root
DB_NAME: volctraindb
ports:
- "8888:8888"
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
- volctrain-dev
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8888/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
command: ["api"]
volumes:
mysql_dev_data:
redis_dev_data:
networks:
volctrain-dev:
driver: bridge