# Sinhala TTS VITS — Docker Production Deployment # # Build: docker build -t sinhala-tts-server . # Run: docker run -p 8081:8081 sinhala-tts-server # # The server listens on port 8081 (aligned with the sandbox backend port). # ── Stage 1: Build ────────────────────────────────────────────────────── FROM python:3.10-slim AS builder # Install system build dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ git \ && rm -rf /var/lib/apt/lists/* WORKDIR /build # Install Coqui TTS and dependencies RUN pip install --no-cache-dir --upgrade pip setuptools wheel # Pin transformers to avoid long-timeouts on model downloads and avoid MPS issue RUN pip install --no-cache-dir \ "coqui-tts>=0.27.0" \ "torch>=2.0.0,<3.0.0" \ "numpy<2.0.0" \ "soundfile>=0.12.0" \ "safetensors>=0.4.0" \ "fastapi>=0.100.0" \ "uvicorn[standard]>=0.23.0" \ "pydantic>=2.0.0" \ "transformers>=4.36.0,<5.0.0" # Clean up pip cache RUN pip cache purge || true # ── Stage 2: Runtime ──────────────────────────────────────────────────── FROM python:3.10-slim AS runtime # Install runtime system dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ libsndfile1 \ curl \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Copy Python packages from builder COPY --from=builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages COPY --from=builder /usr/local/bin /usr/local/bin # Copy model files COPY server.py . COPY config.json . COPY speakers.json . COPY sinhala_tts_vits_model.safetensors . # Expose server port EXPOSE 8081 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:8081/health || exit 1 # Run FastAPI server with uvicorn CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8081"]