| |
| |
| |
| |
| FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 |
|
|
| |
| 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 |
|
|
| |
| RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 1 \ |
| && update-alternatives --install /usr/bin/pip pip /usr/bin/pip3 1 |
|
|
| |
| 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 |
|
|
| |
| RUN pip install --no-cache-dir --upgrade pip |
|
|
| |
| COPY requirements.txt . |
| RUN pip install --no-cache-dir -r requirements.txt |
|
|
| |
| |
| |
| |
| |
| |
| 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" |
|
|
| |
| 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 |
|
|
| |
| 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") |
|
|
| |
| 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 |
|
|
| |
| COPY app.py . |
|
|
| |
| RUN useradd -m -u 1000 user \ |
| && mkdir -p /data \ |
| && chown -R user:user /data /app |
| USER user |
|
|
| EXPOSE 7860 |
|
|
| CMD ["python", "app.py"] |