FROM python:3.9-slim # Install system dependencies including ffmpeg RUN apt-get update && apt-get install -y \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Create user for Hugging Face Spaces (user ID 1000) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Copy requirements first for better caching COPY --chown=user requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy application code COPY --chown=user . . # Expose port 7860 (required for Hugging Face Spaces) EXPOSE 7860 # Run the application on port 7860 CMD ["python", "main.py"]