-
-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathdocker-compose.prod.yml
More file actions
60 lines (54 loc) · 1.48 KB
/
Copy pathdocker-compose.prod.yml
File metadata and controls
60 lines (54 loc) · 1.48 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
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
# API 由宿主机 monorepo server/ 提供(pnpm run start:api 或 pm2:api)
# nginx 通过 host.docker.internal:3002 转发 /api
client:
build:
context: .
dockerfile: client/Dockerfile
container_name: reactpress_client
restart: always
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:
- "${NGINX_PORT:-80}:80"
depends_on:
- client
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
networks:
- reactpress-network
volumes:
db_data:
networks:
reactpress-network:
driver: bridge