Spaces:
Sleeping
Sleeping
Download docker/Dockerfile.api from darshhh32/nutrivision-ai: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/darshhh32/nutrivision-ai/resolve/main/docker/Dockerfile.api
- Command line
-
hf download hf://spaces/darshhh32/nutrivision-ai/docker/Dockerfile.api
-
curl -L -o Dockerfile.api https://huggingface.co/spaces/darshhh32/nutrivision-ai/resolve/main/docker/Dockerfile.api
1.29 kB
| # 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"] | |