FROM python:3.11-slim # Prevent interactive prompts during package installation ENV DEBIAN_FRONTEND=noninteractive \ PYTHONUNBUFFERED=1 # Install system dependencies (FFmpeg for video/audio processing, fonts for subtitles, curl for health checks) RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ curl \ fonts-dejavu-core \ && rm -rf /var/lib/apt/lists/* # Hugging Face Spaces run with UID 1000 non-root user RUN useradd -m -u 1000 user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ HF_HOME=/home/user/.cache # Set up app working directory WORKDIR $HOME/app # Install Python dependencies first for caching efficiency COPY --chown=user:user requirements.txt $HOME/app/ RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy all project code with proper non-root ownership COPY --chown=user:user . $HOME/app # Ensure the worker's local artifact cache is writable. Production status and # queue state live in MongoDB; this directory only holds temporary media. RUN mkdir -p $HOME/app/runs && chmod -R 777 $HOME/app/runs # Switch to non-root user USER user # Hugging Face Space default HTTP port EXPOSE 7860 # Launch the canonical FastAPI worker with Uvicorn CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]