qwen2api commited on
Commit
e24419c
·
verified ·
1 Parent(s): 5b70835

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +1 -105
Dockerfile CHANGED
@@ -1,105 +1 @@
1
- # ============ Source Stage ============
2
- FROM alpine/git AS source
3
-
4
- WORKDIR /repo
5
- RUN git clone --recurse-submodules --depth=1 \
6
- https://github.com/liuzhao1225/YouDub-webui.git . \
7
- && rm -rf .git
8
-
9
- # ============ Frontend Build Stage ============
10
- FROM node:20-slim AS frontend-builder
11
-
12
- WORKDIR /build
13
- COPY --from=source /repo/apps/web/ .
14
-
15
- # Create basic auth middleware (WEB_USERNAME / WEB_PASSWORD at runtime)
16
- RUN mkdir -p src && cat > src/middleware.ts << 'MIDEOF'
17
- import { NextRequest, NextResponse } from "next/server";
18
-
19
- export function middleware(req: NextRequest) {
20
- const password = process.env.WEB_PASSWORD;
21
- if (!password) return NextResponse.next();
22
-
23
- const header = req.headers.get("authorization");
24
- if (header) {
25
- const [user, pwd] = atob(header.slice(6)).split(":");
26
- if (user === (process.env.WEB_USERNAME || "admin") && pwd === password)
27
- return NextResponse.next();
28
- }
29
-
30
- return new NextResponse("Unauthorized", {
31
- status: 401,
32
- headers: { "WWW-Authenticate": "Basic realm=\"YouDub WebUI\"" },
33
- });
34
- }
35
-
36
- export const config = { matcher: "/:path*" };
37
- MIDEOF
38
-
39
- RUN npm ci && npm run build
40
-
41
- # ============ Runtime Stage ============
42
- FROM python:3.12-slim-bookworm
43
-
44
- # Build args for pre-downloading models (all default to skip)
45
- # 分离人声与背景音
46
- ARG PRE_DOWNLOAD_DEMUCS=true
47
- # 语音识别
48
- ARG PRE_DOWNLOAD_WHISPER=true
49
- # 生成配音
50
- ARG PRE_DOWNLOAD_VOXCPM=true
51
-
52
- WORKDIR /app
53
-
54
- # Install system runtime deps
55
- RUN apt-get update && apt-get install -y --no-install-recommends \
56
- ffmpeg curl ca-certificates build-essential \
57
- && rm -rf /var/lib/apt/lists/*
58
-
59
- RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
60
- && apt-get install -y nodejs \
61
- && rm -rf /var/lib/apt/lists/*
62
-
63
- # Copy entire source tree
64
- COPY --from=source /repo/ .
65
-
66
- # Install Python dependencies
67
- RUN pip install --no-cache-dir -r requirements.txt
68
-
69
- # Overlay built frontend artifacts
70
- COPY --from=frontend-builder /build/.next apps/web/.next
71
- COPY --from=frontend-builder /build/node_modules apps/web/node_modules
72
-
73
- # Create runtime data directories
74
- RUN mkdir -p data workfolder
75
-
76
- # Pre-download Demucs model (htdemucs_ft, 4 sub-models ~700 MB total) - 分离人声与背景音
77
- RUN if [ "$PRE_DOWNLOAD_DEMUCS" = "true" ]; then \
78
- python -c 'import urllib.request, os; model_dir = os.path.expanduser("~/.cache/torch/hub/checkpoints"); os.makedirs(model_dir, exist_ok=True); [urllib.request.urlretrieve(url, os.path.join(model_dir, url.rsplit("/", 1)[-1])) for url in ["https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/f7e0c4bc-ba3fe64a.th", "https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/d12395a8-e57c48e6.th", "https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/92cfc3b6-ef3bcb9c.th", "https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/04573f0d-f3cf25b2.th"]]'; \
79
- fi
80
-
81
- # Pre-download Whisper model (large-v3-turbo, ~3 GB) - 语音识别
82
- RUN if [ "$PRE_DOWNLOAD_WHISPER" = "true" ]; then \
83
- python -c 'import whisper; whisper._download(whisper._MODELS["large-v3-turbo"], "/root/.cache/whisper", False)'; \
84
- fi
85
-
86
- # Pre-download VoxCPM2 model (~several GB) - 生成配音
87
- RUN if [ "$PRE_DOWNLOAD_VOXCPM" = "true" ]; then \
88
- python -c 'from modelscope import snapshot_download; snapshot_download("OpenBMB/VoxCPM2", local_dir="/app/data/modelscope/OpenBMB__VoxCPM2")'; \
89
- fi
90
-
91
- # Install entrypoint
92
- COPY docker-entrypoint-youduo.sh /usr/local/bin/docker-entrypoint.sh
93
- RUN chmod +x /usr/local/bin/docker-entrypoint.sh
94
-
95
- EXPOSE 7860
96
-
97
- ENV DEVICE=cpu
98
- ENV WORKFOLDER=./workfolder
99
- ENV MODEL_CACHE_DIR=./data/modelscope
100
- ENV BACKEND_PORT=8000
101
- ENV FRONTEND_PORT=7860
102
- ENV WEB_USERNAME=admin
103
- ENV WEB_PASSWORD=admin
104
-
105
- ENTRYPOINT ["docker-entrypoint.sh"]
 
1
+ FROM ghcr.io/smanx/youduo-hf:latest