-
Notifications
You must be signed in to change notification settings - Fork 493
Expand file tree
/
Copy pathdocker-compose-db.yml
More file actions
72 lines (68 loc) · 1.61 KB
/
Copy pathdocker-compose-db.yml
File metadata and controls
72 lines (68 loc) · 1.61 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
# 仅数据库服务 - MySQL, Redis
# 适用于“服务本机运行,数据库容器运行”的开发方式
# 使用方式: docker compose -f docker-compose-db.yml up -d
services:
mysql:
image: mysql:8.0-debian
container_name: xiaozhi-mysql
restart: always
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=abc123456
- MYSQL_DATABASE=xiaozhi
- MYSQL_USER=xiaozhi
- MYSQL_PASSWORD=123456
- LANG=C.UTF-8
- MYSQL_CHARSET=utf8mb4
- MYSQL_COLLATION=utf8mb4_unicode_ci
volumes:
- mysql_data:/var/lib/mysql
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "xiaozhi", "-p123456"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- db-network
deploy:
resources:
limits:
cpus: '2.0'
memory: 1G
reservations:
cpus: '0.5'
memory: 256M
redis:
image: redis:7-alpine
container_name: xiaozhi-redis
restart: always
ports:
- "6379:6379"
command: ["redis-server", "--appendonly", "yes"]
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- db-network
deploy:
resources:
limits:
cpus: '1.0'
memory: 512M
reservations:
cpus: '0.25'
memory: 128M
networks:
db-network:
driver: bridge
volumes:
mysql_data:
redis_data: