-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
230 lines (216 loc) · 5.69 KB
/
Copy pathdocker-compose.yml
File metadata and controls
230 lines (216 loc) · 5.69 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
version: '3.8'
services:
mysql:
image: mysql:8.0
container_name: inkspace-mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: inkspace
MYSQL_USER: inkspace
MYSQL_PASSWORD: inkspace123
TZ: Asia/Shanghai
ports:
- "3306:3306"
volumes:
- mysql_data:/var/lib/mysql
command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-proot"]
interval: 5s
timeout: 3s
retries: 30
networks:
- inkspace-network
redis:
image: redis:7-alpine
container_name: inkspace-redis
restart: always
ports:
- "6379:6379"
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 10
networks:
- inkspace-network
# 数据库初始化服务:自动创建数据库(如果不存在)
db-init:
image: mysql:8.0
container_name: inkspace-db-init
restart: "no"
depends_on:
mysql:
condition: service_healthy
environment:
- MYSQL_ROOT_PASSWORD=root
entrypoint: >
sh -c "
echo 'Waiting for MySQL to be ready...' &&
until mysql -h inkspace-mysql -uroot -proot -e 'SELECT 1' > /dev/null 2>&1; do
echo 'MySQL is not ready yet, waiting...'
sleep 2
done &&
echo 'MySQL is ready, creating database...' &&
mysql -h inkspace-mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS inkspace CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' &&
mysql -h inkspace-mysql -uroot -proot -e \"CREATE USER IF NOT EXISTS 'inkspace'@'%' IDENTIFIED BY 'inkspace123';\" &&
mysql -h inkspace-mysql -uroot -proot -e 'GRANT ALL PRIVILEGES ON inkspace.* TO \"inkspace\"@\"%\";' &&
mysql -h inkspace-mysql -uroot -proot -e 'FLUSH PRIVILEGES;' &&
echo '✅ Database initialization completed!'
"
networks:
- inkspace-network
backend-1:
build:
context: .
dockerfile: Dockerfile
container_name: inkspace-backend-1
restart: always
depends_on:
mysql:
condition: service_healthy
db-init:
condition: service_completed_successfully
redis:
condition: service_started
environment:
- TZ=Asia/Shanghai
volumes:
- ./config:/app/config
- ./uploads:/app/uploads
networks:
- inkspace-network
backend-2:
build:
context: .
dockerfile: Dockerfile
container_name: inkspace-backend-2
restart: always
depends_on:
mysql:
condition: service_healthy
db-init:
condition: service_completed_successfully
redis:
condition: service_started
environment:
- TZ=Asia/Shanghai
volumes:
- ./config:/app/config
- ./uploads:/app/uploads
networks:
- inkspace-network
backend-3:
build:
context: .
dockerfile: Dockerfile
container_name: inkspace-backend-3
restart: always
depends_on:
mysql:
condition: service_healthy
db-init:
condition: service_completed_successfully
redis:
condition: service_started
environment:
- TZ=Asia/Shanghai
volumes:
- ./config:/app/config
- ./uploads:/app/uploads
networks:
- inkspace-network
admin-backend:
build:
context: .
dockerfile: Dockerfile
container_name: inkspace-admin-backend
restart: always
command: ["./admin"]
ports:
- "8083:8083"
depends_on:
mysql:
condition: service_healthy
db-init:
condition: service_completed_successfully
redis:
condition: service_started
environment:
- TZ=Asia/Shanghai
volumes:
- ./config:/app/config
- ./uploads:/app/uploads
networks:
- inkspace-network
scheduler:
build:
context: .
dockerfile: Dockerfile
container_name: inkspace-scheduler
restart: always
command: ["./scheduler"]
depends_on:
mysql:
condition: service_healthy
db-init:
condition: service_completed_successfully
redis:
condition: service_started
environment:
- TZ=Asia/Shanghai
volumes:
- ./config:/app/config
- ./uploads:/app/uploads
networks:
- inkspace-network
blog-frontend:
build:
context: ./web/blog
dockerfile: Dockerfile
container_name: inkspace-blog-frontend
restart: always
# 注意:不直接暴露端口,通过 Nginx 反向代理访问(子域名:is.iceymoss.com)
depends_on:
- backend-1
- backend-2
- backend-3
networks:
- inkspace-network
admin-frontend:
build:
context: ./web/admin
dockerfile: Dockerfile
container_name: inkspace-admin-frontend
restart: always
# 注意:不直接暴露端口,通过 Nginx 反向代理访问(子域名:admin.is.iceymoss.com)
depends_on:
- admin-backend
networks:
- inkspace-network
# Nginx 反向代理(用于子域名访问)
nginx-proxy:
image: nginx:alpine
container_name: inkspace-nginx-proxy
restart: always
ports:
- "80:80"
- "443:443" # HTTPS 端口(如果有 SSL 证书)
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
# 如果有 SSL 证书,取消注释下面这行并配置证书路径
# - ./nginx/ssl:/etc/nginx/ssl:ro
depends_on:
- blog-frontend
- admin-frontend
networks:
- inkspace-network
volumes:
mysql_data:
redis_data:
networks:
inkspace-network:
driver: bridge