FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_DEFAULT_TIMEOUT=600 \ HF_HOME=/app/.cache \ TRANSFORMERS_CACHE=/app/.cache \ HUGGINGFACE_HUB_CACHE=/app/.cache WORKDIR /app # Outils utiles RUN apt-get update && apt-get install -y --no-install-recommends git \ && rm -rf /var/lib/apt/lists/* # Pip à jour RUN pip install --no-cache-dir --upgrade pip setuptools wheel # ⚠️ Torch CPU depuis l'index officiel PyTorch (fiable) RUN pip --retries 5 --default-timeout=600 install --no-cache-dir \ torch==2.3.1+cpu \ -f https://download.pytorch.org/whl/torch_stable.html # Dépendances restantes (sans torch dans requirements.txt) COPY requirements.txt . RUN pip --retries 5 --default-timeout=600 install --no-cache-dir -r requirements.txt # ✅ Crée le dossier cache et donne les droits RUN mkdir -p /app/.cache && chmod -R 777 /app/.cache # Code COPY . . # Port attendu par Hugging Face Spaces (Docker) EXPOSE 7860 CMD ["uvicorn", "app.main:app", "--host","0.0.0.0","--port","7860"]