FROM python:3.9-slim # Install system dependencies (FFmpeg is mandatory) RUN apt-get update && apt-get install -y \ ffmpeg \ libsm6 \ libxext6 \ && rm -rf /var/lib/apt/lists/* # Create a non-root user (Hugging Face best practice) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:${PATH}" WORKDIR /app # Copy and install requirements COPY --chown=user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the app code COPY --chown=user . . # Hugging Face Spaces expects port 7860 EXPOSE 7860 CMD ["python", "app.py"]