FROM python:3.11-slim # ── System dependencies ──────────────────────────────────────────────────────── RUN apt-get update && apt-get install -y --no-install-recommends \ git \ git-lfs \ curl \ ffmpeg \ espeak-ng \ libsndfile1 \ build-essential \ && git lfs install \ && rm -rf /var/lib/apt/lists/* # ── Create app user ──────────────────────────────────────────────────────────── RUN useradd -m -u 1000 appuser WORKDIR /app # ── Python dependencies ──────────────────────────────────────────────────────── COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # ✅ Install spaCy English model PROPERLY (this fixes a/b pipelines) RUN python -m spacy download en_core_web_sm # ── App files ───────────────────────────────────────────────────────────────── COPY --chown=appuser:appuser main.py . COPY --chown=appuser:appuser static/ ./static/ # ── Runtime directories ──────────────────────────────────────────────────────── RUN mkdir -p /app/audio_output && chown -R appuser:appuser /app # ── Switch to non-root user ──────────────────────────────────────────────────── USER appuser # ── Cache model weights ──────────────────────────────────────────────────────── RUN python -c "from kokoro import KModel; KModel(repo_id='hexgrad/Kokoro-82M')" || true # ── Expose port ──────────────────────────────────────────────────────────────── EXPOSE 7860 # ── Start server ─────────────────────────────────────────────────────────────── CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "3"]