voice-cloning-backend / Dockerfile
AJ50's picture
Add on-demand XTTS model download via setup_models.py
1b05367
FROM python:3.11-slim
# Install system dependencies including build tools and BLAS/LAPACK for scipy
RUN apt-get update && apt-get install -y \
build-essential \
libsndfile1 libsndfile1-dev \
ffmpeg \
git \
libblas-dev liblapack-dev gfortran \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy entire project
COPY . .
# Install Python dependencies
RUN pip install --no-cache-dir -r backend/requirements.txt
# Note: XTTS model downloads on first startup (via setup_models.py)
# - English models: Local (already in repo)
# - Hindi XTTS: Downloaded from HF Hub to /app/backend/models/ on first deployment
# Expose port (HF Spaces uses 7860)
EXPOSE 7860
# Setup models and start app
RUN echo "#!/bin/bash\nset -e\necho '[Startup] Ensuring models are available...'\npython /app/backend/setup_models.py\necho '[Startup] Models ready, starting gunicorn...'\nexec gunicorn --bind 0.0.0.0:7860 --workers 1 --timeout 300 backend.wsgi:app" > /app/start.sh && chmod +x /app/start.sh
# Start the application
CMD ["/app/start.sh"]