fix: use CPU-only torch index (~200MB), split requirements
This commit is contained in:
+11
-15
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user