Spaces:
Sleeping
Sleeping
File size: 952 Bytes
3038662 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # 1. Utiliser une image Python légère
FROM python:3.9-slim
# 2. Forcer Python à afficher les logs immédiatement (évite le silence en cas de crash)
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# 3. Définir le répertoire de travail
WORKDIR /app
# 4. Installer les dépendances système
RUN apt-get update && apt-get install -y \
libgomp1 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 5. Créer l'utilisateur non-root (obligatoire pour HF)
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
# 6. Copier et installer les dépendances
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# 7. Copier le reste du code
COPY --chown=user . .
# 8. Port par défaut Hugging Face
EXPOSE 7860
# 9. Lancer l'application
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "debug"] |