FROM python:3.11-slim # Install system ffmpeg RUN apt-get update && \ apt-get install -y --no-install-recommends ffmpeg && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Create a non-root user (HF Spaces requirement) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH WORKDIR /home/user/app # Install Python dependencies COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy application files COPY --chown=user app.py . COPY --chown=user templates/ templates/ # Create working directories under /tmp (writable in HF Spaces) RUN mkdir -p /tmp/uploads /tmp/processed EXPOSE 7860 CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]