Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
138 lines (131 loc) · 3.57 KB
/
Copy pathdocker-compose.yml
File metadata and controls
138 lines (131 loc) · 3.57 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
version: '3.8'
services:
# MySQL 数据库
mysql:
image: mysql:8.0
container_name: fastmovie-mysql
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-root123456}
MYSQL_DATABASE: ${DB_NAME:-fastmovie}
MYSQL_USER: ${DB_USER:-fastmovie}
MYSQL_PASSWORD: ${DB_PASSWORD:-fastmovie123}
TZ: Asia/Shanghai
volumes:
- mysql_data:/var/lib/mysql
- ./fastmovie-admin/database.sql:/docker-entrypoint-initdb.d/init.sql
ports:
- "${DB_PORT:-3306}:3306"
networks:
- fastmovie-network
command: --default-authentication-plugin=mysql_native_password
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD:-root123456}"]
interval: 10s
timeout: 5s
retries: 5
# Redis 缓存服务
redis:
image: redis:7-alpine
container_name: fastmovie-redis
command: redis-server --requirepass ${REDIS_PASSWORD:-redis123456}
volumes:
- redis_data:/data
ports:
- "${REDIS_PORT:-6379}:6379"
networks:
- fastmovie-network
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-redis123456}", "ping"]
interval: 10s
timeout: 3s
retries: 5
# PHP 后端服务
backend:
build:
context: ./fastmovie-admin
dockerfile: Dockerfile
container_name: fastmovie-backend
working_dir: /var/www/html
environment:
- TZ=Asia/Shanghai
- DB_HOST=mysql
- DB_PORT=3306
- DB_NAME=${DB_NAME:-fastmovie}
- DB_USER=${DB_USER:-fastmovie}
- DB_PASSWORD=${DB_PASSWORD:-fastmovie123}
- REDIS_HOST=redis
- REDIS_PORT=6379
- REDIS_PASSWORD=${REDIS_PASSWORD:-redis123456}
- SERVER_PORT=36300
- PUSH_API_PORT=36301
- PUSH_WSS_PORT=36302
- PUSH_KEY=${PUSH_KEY:-}
- PUSH_SECRET=${PUSH_SECRET:-}
volumes:
- ./fastmovie-admin:/var/www/html
- backend_vendor:/var/www/html/vendor
- backend_runtime:/var/www/html/runtime
ports:
- "${BACKEND_PORT:-36300}:36300"
- "${PUSH_API_PORT:-36301}:36301"
- "${PUSH_WSS_PORT:-36302}:36302"
networks:
- fastmovie-network
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
command: php start.php start -d
# 前端构建服务
frontend:
build:
context: ./fastmovie-vue
dockerfile: Dockerfile
args:
- VITE_API_URL=http://localhost:${BACKEND_PORT:-36300}
- VITE_REQUEST_BASE_URL=http://localhost:${BACKEND_PORT:-36300}
container_name: fastmovie-frontend
volumes:
- frontend_dist:/app/dist
- ./fastmovie-vue:/app
networks:
- fastmovie-network
depends_on:
- backend
# Nginx 反向代理服务
nginx:
image: nginx:alpine
container_name: fastmovie-nginx
ports:
- "${NGINX_HTTP_PORT:-80}:80"
- "${NGINX_HTTPS_PORT:-443}:443"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
- ./nginx.d:/etc/nginx/conf.d:ro
- frontend_dist:/usr/share/nginx/html:ro
- ./fastmovie-admin/public:/var/www/backend:ro
networks:
- fastmovie-network
depends_on:
- backend
- frontend
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"]
interval: 30s
timeout: 10s
retries: 3
volumes:
mysql_data:
driver: local
redis_data:
driver: local
backend_vendor:
driver: local
backend_runtime:
driver: local
frontend_dist:
driver: local
networks:
fastmovie-network:
driver: bridge