marsa-moderation-api / Dockerfile
sahra02's picture
Update Dockerfile
5265981 verified
# Dockerfile pour Hugging Face Spaces
FROM python:3.10-slim
WORKDIR /app
# Installer les dépendances système nécessaires
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# Copier les fichiers de dépendances
COPY requirements.txt .
# Installer les dépendances Python
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copier tous les fichiers de l'application
COPY . .
# Télécharger le modèle YOLO au build time (pour éviter de le télécharger à chaque démarrage)
RUN python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')" || echo "YOLO download skipped"
# Exposer le port 7860 (requis par Hugging Face Spaces)
EXPOSE 7860
# Commande pour lancer l'API FastAPI avec uvicorn
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]