Spaces:
Sleeping
Sleeping
File size: 1,292 Bytes
c0afe44 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # syntax=docker/dockerfile:1
# ============================================================
# NutriVision AI - FastAPI backend image (includes the model)
# ============================================================
FROM python:3.11-slim
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /app
# System libraries required by OpenCV/Ultralytics + curl for healthchecks.
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 libgl1 curl \
&& rm -rf /var/lib/apt/lists/*
# Install CPU-only PyTorch first — dramatically smaller than the CUDA build.
RUN pip install --index-url https://download.pytorch.org/whl/cpu \
torch torchvision
# Python dependencies (torch/torchvision already satisfied above).
COPY requirements.txt ./
RUN pip install -r requirements.txt
# Application source (includes models/weights/best.pt when present).
COPY . .
RUN pip install -e .
# Run as an unprivileged user.
RUN useradd --create-home appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=45s --retries=3 \
CMD curl -fsS http://localhost:8000/health || exit 1
ENTRYPOINT ["bash", "docker/entrypoint-api.sh"]
|