FROM python:3.11-slim # ── System packages ────────────────────────────────────────────────────────── # espeak-ng + libsndfile1: required by piper-tts at runtime # build-essential + cmake + git: required to compile llama-cpp-python from source RUN apt-get update && apt-get install -y --no-install-recommends \ espeak-ng \ libsndfile1 \ ffmpeg \ build-essential \ cmake \ git \ pkg-config \ && rm -rf /var/lib/apt/lists/* # ── HF Spaces requirement: non-root user uid 1000 ──────────────────────────── RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONUNBUFFERED=1 WORKDIR /home/user/app # ── Python dependencies ─────────────────────────────────────────────────────── # CMAKE_BUILD_PARALLEL_LEVEL=1 limits llama-cpp-python C++ compilation to a # single parallel job, reducing peak RAM from ~12 GB (all CPUs) to ~3 GB. # Without this the build container is OOMKilled before compilation finishes. COPY --chown=user requirements.txt . ENV CMAKE_BUILD_PARALLEL_LEVEL=1 RUN pip install --no-cache-dir -r requirements.txt # ── Application ─────────────────────────────────────────────────────────────── COPY --chown=user . . EXPOSE 7860 CMD ["python", "app.py"]