text_to_speech_7 / Dockerfile
muhammadnoman76's picture
update
396e557
FROM python:3.10-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
libsndfile1 \
wget \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy requirements first for better caching
COPY requirements.txt .
# Install PyTorch CPU-only version first (much smaller and faster)
RUN pip install --no-cache-dir torch==2.5.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu
# Install remaining Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Download spacy model during build to avoid runtime network calls
RUN python -m spacy download en_core_web_sm
# Copy application code
COPY app.py .
# Create directory for models (they will be downloaded on first run)
RUN mkdir -p /app/models
# Set environment variables
ENV PYTHONUNBUFFERED=1
# Expose port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Run the application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]