Spaces:
Running
Running
| FROM python:3.11-slim | |
| # Évite les prompts apt + bytecode cache | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| HF_HUB_DISABLE_TELEMETRY=1 | |
| # HF Spaces s'attend à un user non-root pour les writes (cache HF, etc.) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR /home/user/app | |
| # Install Python deps en premier (cache layer) | |
| COPY --chown=user:user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Copy app + warm download du modèle au build (évite cold start sur 1er hit) | |
| COPY --chown=user:user app.py . | |
| # Pre-download le modèle dans le cache HF du container (~800 Mo) | |
| # Économise ~60s sur le 1er request post-deploy | |
| RUN python -c "from transformers import AutoModel, AutoProcessor; \ | |
| AutoModel.from_pretrained('invensync/siglip2-base-invensync-v1'); \ | |
| AutoProcessor.from_pretrained('invensync/siglip2-base-invensync-v1')" | |
| EXPOSE 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |