-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
280 lines (267 loc) · 7.6 KB
/
docker-compose.yml
File metadata and controls
280 lines (267 loc) · 7.6 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# Shared fragments (YAML anchors)
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
x-logging: &default-logging
driver: "json-file"
options:
max-size: "50m"
max-file: "5"
x-backend-env: &backend-env
TZ: ${TZ:-Asia/Taipei}
PUID: ${PUID:-1042}
PGID: ${PGID:-1042}
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER:-vault}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-vault}
x-backend-depends: &backend-depends
postgres:
condition: service_healthy
redis:
condition: service_healthy
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
services:
nginx:
build: ./nginx
ports:
- "${HTTP_PORT:-35689}:80"
environment:
- NGINX_CLIENT_MAX_BODY_SIZE=${NGINX_CLIENT_MAX_BODY_SIZE:-100m}
volumes:
- app_data:/data:ro
depends_on:
api:
condition: service_healthy
pwa:
condition: service_healthy
networks:
- frontend
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget -q --spider http://127.0.0.1/nginx-health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '1'
memory: 256M
reservations:
memory: 128M
logging: *default-logging
api:
build:
context: ./backend
args:
APP_VERSION: ${APP_VERSION:-dev}
command: uvicorn main:app --host 0.0.0.0 --port 8000 --proxy-headers --forwarded-allow-ips='172.16.0.0/12,192.168.0.0/16,10.0.0.0/8'
# user: managed by entrypoint.sh via gosu (PUID/PGID, default 1042:1042)
stop_grace_period: 30s
environment:
<<: *backend-env
env_file: "${JYZROX_ENV_FILE:-.env}"
volumes:
- app_data:/data
- ./config/gallery-dl:/home/appuser/.config/gallery-dl
- gallery_dl_venv:/opt/gallery-dl:ro
depends_on:
<<: *backend-depends
networks:
- frontend
- backend
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget -qO /dev/null http://localhost:8000/api/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
memory: 512M
logging: *default-logging
worker:
build:
context: ./backend
args:
APP_VERSION: ${APP_VERSION:-dev}
command: python -m worker
# user: managed by entrypoint.sh via gosu (PUID/PGID, default 1042:1042)
stop_grace_period: 55s
environment:
<<: *backend-env
WORKER_CONCURRENCY_INTERACTIVE: ${WORKER_CONCURRENCY_INTERACTIVE:-6}
WORKER_CONCURRENCY_INGEST: ${WORKER_CONCURRENCY_INGEST:-4}
WORKER_CONCURRENCY_RENDER: ${WORKER_CONCURRENCY_RENDER:-2}
env_file: "${JYZROX_ENV_FILE:-.env}"
volumes:
- app_data:/data
# host: chown 1042:1042 ./config/gallery-dl && chmod 750 ./config/gallery-dl
- ./config/gallery-dl:/home/appuser/.config/gallery-dl
- gallery_dl_venv:/opt/gallery-dl
depends_on:
<<: *backend-depends
networks:
- frontend
- backend
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "python3 -c 'import os,signal; os.kill(1, 0)' || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 10s
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
memory: 512M
logging: *default-logging
pwa:
build:
context: ./pwa
args:
APP_VERSION: ${APP_VERSION:-dev}
environment:
- TZ=${TZ:-Asia/Taipei}
- NODE_ENV=production
- NEXT_TELEMETRY_DISABLED=1
depends_on:
- api
networks:
- frontend
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://127.0.0.1:3000"]
interval: 30s
timeout: 5s
retries: 3
start_period: 15s
deploy:
resources:
limits:
cpus: '1'
memory: 512M
reservations:
memory: 256M
logging: *default-logging
tagger:
build: ./tagger
environment:
- TZ=${TZ:-Asia/Taipei}
- TAG_MODEL_NAME=${TAG_MODEL_NAME:-SmilingWolf/wd-swinv2-tagger-v3}
- ONNX_PROVIDERS=${ONNX_PROVIDERS:-CPUExecutionProvider}
volumes:
- app_data:/data:ro
- tagger_models:/app/models
networks:
- backend
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "wget -qO /dev/null http://localhost:8100/health || exit 1"]
interval: 30s
timeout: 5s
retries: 3
start_period: 60s
deploy:
resources:
limits:
cpus: '2'
memory: 3G
reservations:
memory: 1G
profiles:
- tagging
logging: *default-logging
postgres:
image: postgres:18-alpine
command: >
postgres
-c password_encryption=scram-sha-256
-c log_connections=on
-c log_disconnections=on
env_file: "${JYZROX_ENV_FILE:-.env}"
volumes:
- postgres_data:/var/lib/postgresql
- ./db/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER:-vault} -d $${POSTGRES_DB:-vault} && psql -U $${POSTGRES_USER:-vault} -d $${POSTGRES_DB:-vault} -c 'SELECT 1' -q -t"]
interval: 30s
timeout: 5s
retries: 10
networks:
- backend
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
deploy:
resources:
limits:
cpus: '2'
memory: 2G
reservations:
memory: 512M
logging: *default-logging
redis:
image: redis:8-alpine
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD} --maxmemory ${REDIS_MAXMEMORY:-768mb} --maxmemory-policy allkeys-lru --auto-aof-rewrite-percentage 100 --auto-aof-rewrite-min-size 64mb
volumes:
- redis_data:/data
healthcheck:
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "--no-auth-warning", "ping"]
interval: 30s
timeout: 3s
retries: 5
networks:
- backend
security_opt: ["no-new-privileges:true"]
restart: unless-stopped
deploy:
resources:
limits:
cpus: '1'
memory: 1G
reservations:
memory: 256M
logging: *default-logging
volumes:
app_data:
driver: local
driver_opts:
type: none
o: bind
device: ${JYZROX_DATA_ROOT}/data
postgres_data:
driver: local
driver_opts:
type: none
o: bind
device: ${JYZROX_DATA_ROOT}/postgres
redis_data:
driver: local
driver_opts:
type: none
o: bind
device: ${JYZROX_DATA_ROOT}/redis
tagger_models:
gallery_dl_venv:
driver: local
driver_opts:
type: none
o: bind
device: ${JYZROX_DATA_ROOT}/gallery-dl-venv
networks:
frontend:
name: jyzrox_frontend
backend:
name: jyzrox_backend
internal: true