Video_Dub / Dockerfile
7RiKuSama's picture
Update Dockerfile
108fc7b verified
Raw
History Blame Contribute Delete
6.06 kB
# ─────────────────────────────────────────────────────────────────────────────
# AutoDub β€” HuggingFace Spaces Dockerfile
# Base: CUDA 12.1 + cuDNN 8 + Ubuntu 22.04 (matches HF ZeroGPU A100 driver)
# ─────────────────────────────────────────────────────────────────────────────
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
# ── System packages ───────────────────────────────────────────────────────────
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
git \
wget \
curl \
ca-certificates \
ffmpeg \
libass-dev \
libass9 \
fonts-noto \
fonts-noto-core \
fonts-noto-cjk \
fonts-noto-extra \
fonts-noto-ui-core \
fonts-noto-unhinted \
libsndfile1 \
libsndfile1-dev \
python3.10 \
python3.10-dev \
python3-pip \
python3.10-venv \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
&& fc-cache -fv
# ── Python alias ──────────────────────────────────────────────────────────────
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 \
&& update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1
# ── HuggingFace cache dirs ────────────────────────────────────────────────────
ENV HF_HOME=/data/.huggingface
ENV TRANSFORMERS_CACHE=/data/.huggingface/hub
ENV XDG_CACHE_HOME=/data/.cache
ENV COQUI_TOS_AGREED=1
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
WORKDIR /app
# ── Step 1: upgrade pip only ──────────────────────────────────────────────────
RUN pip install --no-cache-dir --upgrade pip
# ── Step 2: install all app requirements FIRST ───────────────────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ── Step 3: force-install pinned versions AFTER requirements ─────────────────
# - gradio 4.19.2: stable version without the Jinja2 dict/cache bug
# - gradio_client 0.10.1: exact version required by gradio 4.19.2
# - huggingface_hub 0.23.4: last version before HfFolder was removed
# - numpy 1.26.4: coqui-tts Cython extensions require numpy 1.x
# - fastapi/starlette: locked to versions gradio 4.19.2 was tested against
RUN pip install --no-cache-dir --upgrade --force-reinstall \
"gradio==4.19.2" \
"gradio_client==0.10.1" \
"huggingface_hub==0.23.4" \
"numpy==1.26.4" \
"fastapi==0.110.3" \
"starlette==0.37.2" \
"httpx>=0.24.0" \
"anyio>=4.4.0"
# ── Step 4: patch gradio_client bool/dict bug ─────────────────────────────────
RUN python - <<'PYEOF'
import pathlib
p = pathlib.Path("/usr/local/lib/python3.10/dist-packages/gradio_client/utils.py")
if not p.exists():
print("gradio_client not found, skipping patch")
exit(0)
src = p.read_text()
original = src
# ── Patch 1: guard get_type() ─────────────────────────────────────────────────
old1 = 'def get_type(schema: dict):\n if "const" in schema:'
new1 = 'def get_type(schema: dict):\n if not isinstance(schema, dict):\n return "any"\n if "const" in schema:'
if old1 in src:
src = src.replace(old1, new1)
print("Patch 1 (get_type) applied OK")
else:
print("Patch 1 pattern not found")
# ── Patch 2: guard _json_schema_to_python_type() ─────────────────────────────
old2 = 'def _json_schema_to_python_type(schema: Any, defs) -> str:\n """Convert the json schema into a python type hint"""\n if schema == {}:'
new2 = 'def _json_schema_to_python_type(schema: Any, defs) -> str:\n """Convert the json schema into a python type hint"""\n if not isinstance(schema, dict):\n return "any"\n if schema == {}:'
if old2 in src:
src = src.replace(old2, new2)
print("Patch 2 (_json_schema_to_python_type) applied OK")
else:
print("Patch 2 exact match failed β€” trying line-by-line search")
lines = src.splitlines()
for i, line in enumerate(lines):
if 'def _json_schema_to_python_type' in line:
print(f" Found at line {i}: {line!r}")
if i+1 < len(lines): print(f" Next line {i+1}: {lines[i+1]!r}")
if i+2 < len(lines): print(f" Next line {i+2}: {lines[i+2]!r}")
break
if src != original:
p.write_text(src)
print("gradio_client utils.py patched and written successfully")
else:
print("WARNING: No changes written β€” patch did not match")
PYEOF
# ── Application code ──────────────────────────────────────────────────────────
COPY app.py .
# ── Non-root user required by HuggingFace Spaces ─────────────────────────────
RUN useradd -m -u 1000 user \
&& mkdir -p /data \
&& chown -R user:user /data /app
USER user
EXPOSE 7860
CMD ["python", "app.py"]