forked from JefferyHcool/BiliNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.gpu.yml
More file actions
68 lines (65 loc) · 2.06 KB
/
Copy pathdocker-compose.gpu.yml
File metadata and controls
68 lines (65 loc) · 2.06 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
services:
backend:
container_name: bilinote-backend
build:
context: .
dockerfile: backend/Dockerfile.gpu
args:
# 国内拉不到 docker.io 时设置 BASE_REGISTRY;注意所选镜像需要支持 nvidia/cuda 命名空间
BASE_REGISTRY: ${BASE_REGISTRY:-docker.io}
APT_MIRROR: ${APT_MIRROR:-mirrors.tuna.tsinghua.edu.cn}
PIP_INDEX: ${PIP_INDEX:-https://pypi.tuna.tsinghua.edu.cn/simple}
env_file:
- .env
environment:
- BACKEND_PORT=${BACKEND_PORT}
- BACKEND_HOST=${BACKEND_HOST}
volumes:
# 同 docker-compose.yml:./backend 绑到 /app,DB / 转写器配置 / 截图 / 上传都持久化
- ./backend:/app
expose:
- "${BACKEND_PORT}" # 不再对外暴露,用于 nginx 内部通信
# 用 unless-stopped 避免短暂崩溃把容器永久打死后再也读不到 .env 修改
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${BACKEND_PORT}/api/sys_health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s # GPU 镜像首次加载 CUDA 比 CPU 慢,给久一点
# GPU 部署默认跑较大模型,把内存限制提到 8g 避免 host OOM
mem_limit: 8g
deploy:
resources:
reservations:
devices:
- driver: "nvidia"
count: "all"
capabilities: ["gpu"]
frontend:
container_name: bilinote-frontend
build:
context: .
dockerfile: BillNote_frontend/Dockerfile
args:
BASE_REGISTRY: ${BASE_REGISTRY:-docker.io}
env_file:
- .env
expose:
- "80" # 不暴露给宿主机,只供 nginx 访问
restart: unless-stopped
mem_limit: 512m
nginx:
container_name: bilinote-nginx
image: nginx:1.25-alpine
ports:
- "${APP_PORT}:80"
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
backend:
condition: service_healthy
frontend:
condition: service_started
restart: unless-stopped
mem_limit: 256m