Files
stack/infra/images/api.Dockerfile
kert 81dba5ef2a
All checks were successful
CI / lint (push) Successful in 37s
CI / notebooks-smoke (push) Successful in 1m26s
Deploy / notebooks (push) Has been skipped
Deploy / zotero (push) Has been skipped
Deploy / docs (push) Has been skipped
Deploy / api (push) Successful in 1m17s
Deploy / mc (push) Has been skipped
Infra CI / notebooks (push) Successful in 46s
Infra CI / zotero (push) Successful in 15s
Infra CI / docs (push) Successful in 12s
Infra CI / api (push) Successful in 12s
Infra CI / mc (push) Successful in 18s
Deploy / report (push) Successful in 12s
CI / test (push) Successful in 13m49s
fix(api): install cli extra bundle in image — bare sync shipped no uvicorn
First rebuild in 3 months surfaced this: pyproject moved uvicorn/
fastapi/aco/bib into extras since the last api image build, so
'uv sync --no-dev' produced a venv with base deps only and the
container crash-looped on 'Failed to spawn: uvicorn'. infra-ci builds
the image but nothing boots it, so the break was invisible until a
real deploy.
2026-07-10 13:50:30 -04:00

45 lines
1.6 KiB
Docker

# syntax=docker/dockerfile:1
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
WORKDIR /app
# Local package registry (Gitea) — set via --build-arg to pull from mirror
ARG PYPI_INDEX_URL=""
# Patch base image CVEs + install curl for healthcheck.
# (Python cold-start on this image is 10-13s — too slow for the 5s
# healthcheck timeout, so Docker marks the container unhealthy even
# though /health responds in milliseconds.)
RUN apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends curl && rm -rf /var/lib/apt/lists/*
# Copy project files for install
COPY pyproject.toml uv.lock README.md ./
COPY src/ src/
# Install the package (no dev deps). The server needs the cli extra
# bundle (aco + api + bib + mail): uvicorn/fastapi/pyjwt live in the
# api extra, and /health imports aco.pipe + bib.store + duckdb — a
# bare `uv sync --no-dev` installs none of them (base deps only),
# which shipped an image that crash-looped on `Failed to spawn:
# uvicorn`.
ENV UV_PYTHON_PREFERENCE=only-system \
UV_LINK_MODE=copy \
UV_PROJECT_ENVIRONMENT=.venv \
UV_INDEX_URL=${PYPI_INDEX_URL}
RUN uv sync --no-dev --extra cli && uv pip install -e .
# Config
COPY stack.toml ./
EXPOSE 8000
# --max-time bounds curl itself: docker's timeout only stops *waiting* —
# the probe process lives on, and a wedged server once accumulated ~1500
# hung healthcheck zombies this way.
HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
CMD curl -sf --max-time 4 http://localhost:8000/health || exit 1
CMD ["uv", "run", "--no-sync", "uvicorn", "api.server:app", \
"--host", "0.0.0.0", "--port", "8000", \
"--workers", "1", "--log-level", "info"]