Spaces:
Paused
Paused
| # Use a newer PyTorch image that matches chatterbox-tts requirements | |
| FROM pytorch/pytorch:2.6.0-cuda12.4-cudnn9-runtime | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PORT=7860 | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| libsndfile1 \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Python dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Create a non-root user and switch to it | |
| RUN useradd -m -u 1000 user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR /app | |
| # Create output directory and set permissions before switching user | |
| RUN mkdir -p /app/outputs && chown user:user /app/outputs | |
| # Copy the rest of the application code | |
| COPY --chown=user . . | |
| USER user | |
| # Pre-download the model weights during build time | |
| RUN python download_model.py | |
| # Expose the port (Hugging Face Spaces expects 7860) | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |