Download Dockerfile from gabcares/boq-api: direct link, hf CLI and curl.
- Browser
- Download file 1.72 kB
-
https://huggingface.co/spaces/gabcares/boq-api/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/gabcares/boq-api/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/gabcares/boq-api/resolve/main/Dockerfile
1.72 kB
| # ---- Stage 1: Builder ---- | |
| FROM python:3.12-slim AS builder | |
| # Copy uv binary from Astral's official image | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| WORKDIR /api | |
| # Environment optimizations | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Copy lockfile and project metadata first (to leverage caching) | |
| COPY uv.lock pyproject.toml ./ | |
| # Install dependencies only (non-editable, without project source) | |
| RUN --mount=type=cache,target=/root/.cache/uv \ | |
| uv sync --no-install-project --no-editable | |
| # Copy API source | |
| COPY . . | |
| # Sync project into environment (non-editable) | |
| RUN --mount=type=cache,target=/root/.cache/uv \ | |
| uv sync --no-editable | |
| # ---- Stage 2: Runtime ---- | |
| FROM python:3.12-slim | |
| # Install system dependencies for Chromium (Kaleido) and Healthcheck | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| chromium \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy uv binary again so runtime stage has it | |
| COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ | |
| WORKDIR /api | |
| # Copy virtual environment and app code from builder | |
| COPY --from=builder /api/.venv /api/.venv | |
| COPY --from=builder /api /api | |
| # Ensure venv binaries are on PATH | |
| ENV PATH="/api/.venv/bin:$PATH" | |
| ENV PYTHONDONTWRITEBYTECODE=1 | |
| ENV PYTHONUNBUFFERED=1 | |
| # Expose app port | |
| EXPOSE 7860 | |
| # Silence CUDA and oneDNN warnings if not needed | |
| ENV CUDA_VISIBLE_DEVICES="" | |
| ENV TF_ENABLE_ONEDNN_OPTS=0 | |
| # Liveness probe — instant check, no model dependency | |
| HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \ | |
| CMD curl -f http://localhost:7860/api/v1/health/liveness || exit 1 | |
| # Start application | |
| CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |