Spaces:
Paused
Paused
Download Dockerfile from hari7775/transpeech: direct link, hf CLI and curl.
- Browser
- Download file 2.63 kB
-
https://huggingface.co/spaces/hari7775/transpeech/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/hari7775/transpeech/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/hari7775/transpeech/resolve/main/Dockerfile
2.63 kB
| FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04 | |
| # Avoid interactive prompts during apt-get | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Install system dependencies and Python 3.10 | |
| USER root | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.10 \ | |
| python3-pip \ | |
| python3-dev \ | |
| ffmpeg \ | |
| libharfbuzz-dev \ | |
| gcc \ | |
| wget \ | |
| ca-certificates \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set python3.10 as the default 'python' and 'pip' | |
| RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \ | |
| ln -sf /usr/bin/pip3 /usr/bin/pip | |
| # Create a non-root user | |
| RUN useradd -m -u 1000 user | |
| # Set up the application directory | |
| WORKDIR /app | |
| RUN chown -R user:user /app | |
| # Switch to the non-root user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV OMP_NUM_THREADS=4 | |
| # Create fonts directory and download one Noto Sans face per script the PDF | |
| # exporter can be asked for. Must stay in sync with SCRIPT_FONTS in languages.py: | |
| # a missing file makes PDFs render as empty boxes rather than failing outright, | |
| # so every download is checked and the build stops on the first failure. | |
| RUN mkdir -p fonts && \ | |
| for f in NotoSans NotoSansDevanagari NotoSansBengali NotoSansGurmukhi \ | |
| NotoSansGujarati NotoSansTelugu NotoSansTamil NotoSansKannada \ | |
| NotoSansMalayalam NotoSansArabic NotoSansHebrew NotoSansThai; do \ | |
| wget -O "fonts/${f}-Regular.ttf" \ | |
| "https://github.com/googlefonts/noto-fonts/raw/main/hinted/ttf/${f}/${f}-Regular.ttf" || exit 1; \ | |
| done && \ | |
| for f in SC JP KR; do \ | |
| wget -O "fonts/NotoSans${f}-Regular.ttf" \ | |
| "https://github.com/googlefonts/noto-cjk/raw/main/Sans/SubsetOTF/${f}/NotoSans${f}-Regular.otf" || exit 1; \ | |
| done | |
| # Copy backend requirements and install | |
| # Since this Dockerfile is now in the backend directory, we copy from the local context | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy the backend code. languages.py must be included or the import fails at | |
| # startup — the previous COPY listed app.py alone. | |
| COPY --chown=user app.py languages.py ./ | |
| # Fail the build if a script in languages.py has no matching font file | |
| RUN python -c "import languages, os, sys; \ | |
| missing = [f for f in languages.REQUIRED_FONTS if not os.path.exists(os.path.join('fonts', f))]; \ | |
| sys.exit('Missing fonts: ' + ', '.join(missing)) if missing else print('All %d fonts present' % len(languages.REQUIRED_FONTS))" | |
| # Expose the port used by Hugging Face Spaces | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["python", "app.py"] | |