FROM python:3.11-slim # Install system dependencies # espeak-ng: Required for phonemizer (Coqui TTS) # libsndfile1: Required for soundfile # git: Required if any dependencies are installed from git RUN apt-get update && apt-get install -y \ espeak-ng \ git \ libsndfile1 \ && rm -rf /var/lib/apt/lists/* # Set up a new user named "user" with user ID 1000 RUN useradd -m -u 1000 user # Switch to the "user" user USER user # Set home to the user's home directory ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set working directory to the user's home directory WORKDIR $HOME/app # Copy the current directory contents into the container at $HOME/app setting the owner to the user COPY --chown=user . $HOME/app # Install Python dependencies # We use --user to install to the user's home directory since we don't have root access RUN pip install --no-cache-dir --user -r requirements.txt # Create cache directory for TTS models if it doesn't exist RUN mkdir -p tts_cache && chmod 777 tts_cache # Expose port 7860 (Hugging Face Spaces default) EXPOSE 7860 # Command to run the server CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]