Files
shoottracker/ai-service/Dockerfile
T
2026-04-30 22:59:26 +02:00

38 lines
1.2 KiB
Docker

# ─── ShootTracker AI Service ──────────────────────────────────────────────────
# Python + FastAPI + YOLOv8 + OpenCV (PyTorch CPU-only, ~200MB)
FROM python:3.11-slim
# Dépendances système minimales
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 libgl1 libgomp1 wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# 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
# 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 . .
# Variables d'environnement
ENV PORT=8000
ENV YOLO_MODEL_PATH=yolov8n.pt
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# Healthcheck
HEALTHCHECK --interval=30s --timeout=15s --start-period=120s --retries=5 \
CMD wget -qO- http://localhost:8000/health || exit 1
EXPOSE 8000
CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]