-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
80 lines (74 loc) · 1.9 KB
/
docker-compose.prod.yml
File metadata and controls
80 lines (74 loc) · 1.9 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
version: '3.8'
services:
db:
image: mysql:5.7
container_name: reactpress_db
restart: always
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
MYSQL_DATABASE: ${DB_DATABASE:-reactpress}
MYSQL_USER: ${DB_USER:-reactpress}
MYSQL_PASSWORD: ${DB_PASSWD:-reactpress}
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=mysql_native_password
volumes:
- db_data:/var/lib/mysql
networks:
- reactpress-network
server:
build:
context: .
dockerfile: server/Dockerfile
container_name: reactpress_server
restart: always
depends_on:
- db
environment:
- NODE_ENV=production
# 从.env文件读取环境变量,使用默认值
- DB_HOST=${DB_HOST:-db}
- DB_PORT=${DB_PORT:-3306}
- DB_USER=${DB_USER:-reactpress}
- DB_PASSWD=${DB_PASSWD:-reactpress}
- DB_DATABASE=${DB_DATABASE:-reactpress}
- SERVER_SITE_URL=${SERVER_SITE_URL:-http://localhost:3002}
ports:
- "3002:3002"
networks:
- reactpress-network
client:
build:
context: .
dockerfile: client/Dockerfile
container_name: reactpress_client
restart: always
depends_on:
- server
environment:
- NODE_ENV=production
# 从.env文件读取环境变量,使用默认值
- CLIENT_SITE_URL=${CLIENT_SITE_URL:-http://localhost:3001}
- SERVER_API_URL=${SERVER_API_URL:-http://nginx/api}
ports:
- "3001:3001"
networks:
- reactpress-network
nginx:
image: nginx:alpine
container_name: reactpress_nginx
ports:
- "8080:80"
depends_on:
- client
- server
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
networks:
- reactpress-network
volumes:
db_data:
networks:
reactpress-network:
driver: bridge