scenex-analysis / Dockerfile
JonSnow1512's picture
Upload 5 files
2e32eaa verified
Raw
History Blame Contribute Delete
1.71 kB
# ─────────────────────────────────────────────────────────────────────────────
# SceneX β€” AI Analysis Service (CPU-only)
# Use this when no NVIDIA GPU is available.
# ─────────────────────────────────────────────────────────────────────────────
FROM python:3.11-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
fonts-dejavu-core \
libglib2.0-0 \
libgl1 \
gcc \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install CPU-only torch first to avoid pulling the full CUDA wheel
RUN pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
COPY requirements.txt ./
# Install remaining deps (torch is already satisfied above)
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN python -c "from ultralytics import YOLO; YOLO('yolov8x.pt')" \
|| echo "Weight download skipped β€” will download on first run"
# Fix Ultralytics cache directory permissions so non-root user can write to it
RUN mkdir -p /tmp/Ultralytics && chmod 777 /tmp/Ultralytics
RUN useradd -m scenex && chown -R scenex /app
USER scenex
EXPOSE 8000
HEALTHCHECK --interval=60s --timeout=30s --start-period=120s --retries=3 \
CMD curl -sf http://localhost:8000/docs || exit 1
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]