fix: use CPU-only torch index (~200MB), split requirements
This commit is contained in:
+11
-15
@@ -1,27 +1,23 @@
|
|||||||
# ─── ShootTracker AI Service ──────────────────────────────────────────────────
|
# ─── ShootTracker AI Service ──────────────────────────────────────────────────
|
||||||
# Python + FastAPI + YOLOv8 + OpenCV
|
# Python + FastAPI + YOLOv8 + OpenCV (PyTorch CPU-only, ~200MB)
|
||||||
|
|
||||||
FROM python:3.11-slim
|
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 \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
libglib2.0-0 \
|
libglib2.0-0 libgl1 libgomp1 wget \
|
||||||
libsm6 \
|
|
||||||
libxext6 \
|
|
||||||
libxrender1 \
|
|
||||||
libgl1 \
|
|
||||||
libgomp1 \
|
|
||||||
wget \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copier et installer les dépendances Python
|
# 1. PyTorch CPU-only en premier (index dédié = version légère ~200MB)
|
||||||
COPY requirements.txt .
|
RUN pip install --no-cache-dir \
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
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)
|
# 2. Reste des dépendances (pas de torch/torchvision dans requirements.txt)
|
||||||
RUN python -c "from ultralytics import YOLO; YOLO('yolov8n.pt')" || echo "Download YOLOv8n on first run"
|
COPY requirements-api.txt .
|
||||||
|
RUN pip install --no-cache-dir -r requirements-api.txt
|
||||||
|
|
||||||
# Copier le code
|
# Copier le code
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -33,7 +29,7 @@ ENV PYTHONUNBUFFERED=1
|
|||||||
ENV PYTHONDONTWRITEBYTECODE=1
|
ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
|
|
||||||
# Healthcheck
|
# 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
|
CMD wget -qO- http://localhost:8000/health || exit 1
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user