-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.yml
68 lines (62 loc) · 1.78 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
version: '3.0'
name: simple-chat
services:
mysql:
restart: always
image: mysql:8
container_name: mysql-simple-chat
volumes:
- /usr/simple-chat/mydata/mysql/log:/var/log/mysql
- /usr/simple-chat/mydata/mysql/data:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWD}
- MYSQL_DATABASE=${DB_DATABASE}
ports:
# 使用宿主机的3306端口映射到容器的3306端口
# 宿主机:容器
- "3306:3306"
networks: # 自定义网络
- my-network
redis:
container_name: redis-simple-chat
image: redis:3.0.2
volumes:
- /usr/simple-chat/mydata/redis/data:/data
- /usr/simple-chat/mydata/redis/conf/redis.conf:/etc/redis/redis.conf
ports:
- "6379:6379"
restart: always
networks: # 自定义网络
- my-network
server:
container_name: server-simple-chat
build:
context: .
volumes:
- static-content:/usr/local/simple-chat/packages/static/dist # 将打包生成的静态文件共享到容器的 static-content目录中
ports:
- "3000:3000"
restart: always
depends_on:
- redis
- mysql
networks: # 自定义网络
- my-network
nginx:
image: nginx:1.21.0
container_name: nginx-simple-chat
volumes:
- static-content:/usr/share/nginx/html # 挂载当前静态网页文件目录
- ./config/nginx/default.conf:/etc/nginx/conf.d/default.conf # 挂载 Nginx 配置目录
ports:
- 80:80
# - 443:443
restart: always
networks:
my-network:
depends_on:
- server
networks:
my-network:
volumes:
static-content: # 共享这个容器目录