fix: use CPU-only torch index (~200MB), split requirements

This commit is contained in:
ShootTracker Deploy
2026-04-30 22:59:26 +02:00
parent d5fa458cff
commit e65120b054
2 changed files with 21 additions and 15 deletions
+11 -15
View File
@@ -1,27 +1,23 @@
# ─── ShootTracker AI Service ──────────────────────────────────────────────────
# Python + FastAPI + YOLOv8 + OpenCV
# Python + FastAPI + YOLOv8 + OpenCV (PyTorch CPU-only, ~200MB)
FROM python:3.11-slim
# Dépendances système pour OpenCV (compatibles Debian Bookworm)
# Dépendances système minimales
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgl1 \
libgomp1 \
wget \
libglib2.0-0 libgl1 libgomp1 wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copier et installer les dépendances Python
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# 1. PyTorch CPU-only en premier (index dédié = version légère ~200MB)
RUN pip install --no-cache-dir \
torch==2.3.0 torchvision==0.18.0 \
--index-url https://download.pytorch.org/whl/cpu
# Pré-télécharger le modèle YOLOv8n (pour éviter le téléchargement au premier démarrage)
RUN python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')" || echo "Download YOLOv8n on first run"
# 2. Reste des dépendances (pas de torch/torchvision dans requirements.txt)
COPY requirements-api.txt .
RUN pip install --no-cache-dir -r requirements-api.txt
# Copier le code
COPY . .
@@ -33,7 +29,7 @@ ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Healthcheck
HEALTHCHECK --interval=30s --timeout=15s --start-period=60s --retries=3 \
HEALTHCHECK --interval=30s --timeout=15s --start-period=120s --retries=5 \
CMD wget -qO- http://localhost:8000/health || exit 1
EXPOSE 8000
+10
View File
@@ -0,0 +1,10 @@
fastapi==0.111.0
uvicorn[standard]==0.30.1
python-multipart==0.0.9
pillow==10.3.0
numpy==1.26.4
opencv-python-headless==4.9.0.80
ultralytics==8.2.37
httpx==0.27.0
pydantic==2.7.3
python-dotenv==1.0.1