Spaces:
Running
Running
FROM python:3.11-slim | |
# Set up a new user named "user" with user ID 1000 | |
RUN useradd -m -u 1000 user | |
# Install only essential system dependencies | |
RUN apt-get update && apt-get install -y \ | |
git \ | |
git-lfs \ | |
ffmpeg \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Initialize git lfs | |
RUN git lfs install | |
# Switch to the "user" user | |
USER user | |
# Set environment variables | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH \ | |
COQUI_TOS_AGREED=1 \ | |
HF_HUB_DISABLE_TELEMETRY=1 | |
# Set the working directory | |
WORKDIR $HOME/app | |
# Upgrade pip | |
RUN pip install --no-cache-dir --upgrade pip | |
# Copy and install requirements | |
COPY --chown=user requirements.txt . | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Pre-download the C-3PO model to speed up startup | |
RUN python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='Borcherding/XTTS-v2_C3PO', local_dir='./models/XTTS-v2_C3PO', local_dir_use_symlinks=False)" | |
# Copy the API file | |
COPY --chown=user coqui_api.py . | |
# Expose the port | |
EXPOSE 7860 | |
# Start the C-3PO TTS API | |
CMD ["uvicorn", "coqui_api:app", "--host", "0.0.0.0", "--port", "7860"] |