File size: 2,723 Bytes
64801d5
 
 
 
 
 
 
 
 
 
 
 
 
 
ce950e1
64801d5
 
 
 
 
 
 
 
ce950e1
 
 
64801d5
 
 
 
 
 
 
 
 
 
ce950e1
64801d5
 
ce950e1
64801d5
 
 
10cca2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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"]