# Base image with Python 3.12 FROM python:3.12-slim # Set working directory WORKDIR /app # Install system dependencies # Added ffmpeg for video processing RUN apt-get update && apt-get install -y \ portaudio19-dev \ libsdl-pango-dev \ libcairo2-dev \ libpango1.0-dev \ build-essential \ texlive-full \ wget \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Copy Python files COPY requirements.txt . COPY main.py . COPY src/ ./src/ COPY utils/ ./utils/ COPY prompts/ ./prompts/ # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Download ONNX model if missing RUN mkdir -p src/tts && \ [ ! -f src/tts/kokoro-v1.0.onnx ] && \ wget -O src/tts/kokoro-v1.0.onnx https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.onnx # Setup for Hugging Face Spaces # Create a user with UID 1000 (standard for HF Spaces) RUN useradd -m -u 1000 user # Create writable directories and set permissions RUN mkdir -p output media .nicegui src/tts && \ chown -R user:user /app # Switch to non-root user USER user # Set Environment Variables ENV PYTHONPATH=/app:$PYTHONPATH ENV PORT=7860 # Expose the default HF Spaces port EXPOSE 7860 # Start your Python script CMD ["python", "main.py"]