-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
91 lines (86 loc) · 2.52 KB
/
docker-compose.yml
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
# 创建自定义网络,网络地址 10.1.0.0,默认网关 10.1.0.1,广播地址 10.1.0.255
networks:
my-net:
driver: bridge
name: my-net
ipam:
config:
- subnet: 10.1.0.0/16
# 如果你事先创建了自定义网络,请使用下面的 networks 配置
#networks:
# my-net:
# external: true
services:
mysql:
image: mysql:8.0
container_name: mysql
environment:
MYSQL_ROOT_PASSWORD: 123456 # root 账户密码
MYSQL_DATABASE: ggb # 初始化 mysql 时创建数据库 ggb
volumes:
- /etc/dockerVolumes/mysql/data:/var/lib/mysql # /etc/ 目录不是一成不变的,取决于卷的挂载地址,windows 系统也可以替换成 C:/dockerVolumes
- /etc/dockerVolumes/mysql/mysql.conf.d:/etc/mysql/conf.d:ro
networks:
my-net:
ipv4_address: 10.1.0.2
ports:
- "3307:3306"
restart: unless-stopped
command: [
"--character-set-server=utf8mb4", # 设置字符集
"--collation-server=utf8mb4_general_ci" # 设置排序规则
]
healthcheck:
test: [ "CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p123456" ]
interval: 10s
timeout: 5s
retries: 3
redis:
image: redis:latest
container_name: redis
volumes:
- /etc/dockerVolumes/redis/data:/data
- /etc/dockerVolumes/redis/redis.conf:/usr/local/etc/redis/redis.conf:ro
networks:
my-net:
ipv4_address: 10.1.0.3
ports:
- "6380:6379"
restart: unless-stopped
healthcheck:
test: [ "CMD-SHELL", "redis-cli ping | grep PONG || exit 1" ]
interval: 10s
timeout: 5s
retries: 3
nginx:
image: nginx:latest
container_name: nginx
volumes:
- /etc/dockerVolumes/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- /etc/dockerVolumes/nginx/conf.d:/etc/nginx/conf.d:ro
- /etc/dockerVolumes/nginx/html:/usr/share/nginx/html
- /etc/dockerVolumes/nginx/log:/var/log/nginx
networks:
my-net:
ipv4_address: 10.1.0.4
ports:
- "81:80"
restart: unless-stopped
ggb_server:
image: ggb
container_name: ggb_server
volumes:
- ./log:/go/src/github.com/wangyupo/ggb/server/log
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
networks:
my-net:
ipv4_address: 10.1.0.113
ports:
- "5313:5312"
restart: unless-stopped
environment:
- GIN_MODE=debug