| # Use Python 3.10 slim image | |
| FROM python:3.10-slim | |
| # Install system dependencies | |
| # ffmpeg is required for streaming | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| fonts-dejavu \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set working directory | |
| WORKDIR /app | |
| # Create a non-root user (Hugging Face requirement) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| ENV PYTHONUNBUFFERED=1 | |
| # Copy requirements first to leverage Docker cache | |
| COPY --chown=user ./requirements.txt requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy application code | |
| COPY --chown=user . . | |
| # Command to run the streaming script directly | |
| CMD ["python", "app.py"] | |