| # ===================================================================== | |
| # VerifyAI Backend — HuggingFace Spaces (Docker SDK) | |
| # ===================================================================== | |
| FROM python:3.11-slim | |
| # ---------- System dependencies ---------- | |
| # libgl1 + libglib + libsm/xext/xrender: OpenCV | |
| # libgles2 + libegl1: MediaPipe (precisa mesmo em CPU-only) | |
| # ffmpeg: imageio/pyav (video decoding) | |
| # git: alguns wheels do transformers precisam | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender1 \ | |
| libgles2 \ | |
| libegl1 \ | |
| ffmpeg \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # ---------- Non-root user (HuggingFace Spaces requirement) ---------- | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| HF_HOME=/home/user/.cache/huggingface \ | |
| TRANSFORMERS_CACHE=/home/user/.cache/huggingface \ | |
| MPLCONFIGDIR=/tmp/matplotlib \ | |
| PYTHONUNBUFFERED=1 | |
| WORKDIR $HOME/app | |
| # ---------- Python dependencies ---------- | |
| # torch >= 2.6 é obrigatório pelo transformers (CVE-2025-32434 — pickle .bin) | |
| # CPU-only wheel economiza ~1.5GB vs versão CUDA | |
| RUN pip install --no-cache-dir --user \ | |
| torch==2.6.0 torchvision==0.21.0 \ | |
| --index-url https://download.pytorch.org/whl/cpu | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --user -r requirements.txt | |
| # ---------- Application code ---------- | |
| COPY --chown=user . . | |
| # HuggingFace Spaces expõe na porta 7860 | |
| EXPOSE 7860 | |
| CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |