strive33/Kokoro-TTS-FastAPI
0
1FROM python:3.11-slim2 3# ── System dependencies ────────────────────────────────────────────────────────4RUN apt-get update && apt-get install -y --no-install-recommends \5 git \6 git-lfs \7 curl \8 ffmpeg \9 espeak-ng \10 libsndfile1 \11 build-essential \12 && git lfs install \13 && rm -rf /var/lib/apt/lists/*14 15# ── Create app user ────────────────────────────────────────────────────────────16RUN useradd -m -u 1000 appuser17WORKDIR /app18 19# ── Python dependencies ────────────────────────────────────────────────────────20COPY requirements.txt .21RUN pip install --no-cache-dir --upgrade pip \22 && pip install --no-cache-dir -r requirements.txt23 24# ✅ Install spaCy English model PROPERLY (this fixes a/b pipelines)25RUN python -m spacy download en_core_web_sm26 27# ── App files ─────────────────────────────────────────────────────────────────28COPY --chown=appuser:appuser main.py .29COPY --chown=appuser:appuser static/ ./static/30 31# ── Runtime directories ────────────────────────────────────────────────────────32RUN mkdir -p /app/audio_output && chown -R appuser:appuser /app33 34# ── Switch to non-root user ────────────────────────────────────────────────────35USER appuser36 37# ── Cache model weights ────────────────────────────────────────────────────────38RUN python -c "from kokoro import KModel; KModel(repo_id='hexgrad/Kokoro-82M')" || true39 40# ── Expose port ────────────────────────────────────────────────────────────────41EXPOSE 786042 43# ── Start server ───────────────────────────────────────────────────────────────44CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]