GET /bootstrap returns the 8 sensors, hourly series for all of them, context, meta, and versions in the CONTRACT.md shape. Snapshot artifacts are projected to contract fields once at boot; incomplete artifacts return 503. Adds tests for shape, sensor count, hourly alignment, and versions. Dockerfile now creates UID/GID 10001, uses COPY --chown=10001:10001, and runs as USER 10001:10001. Adds make check and a minimal Gitea Actions workflow that runs the same local gate: uv sync --frozen, compileall, pytest.
45 lines
1.4 KiB
Docker
45 lines
1.4 KiB
Docker
# syntax=docker/dockerfile:1
|
|
FROM python:3.12-slim AS builder
|
|
|
|
COPY --from=ghcr.io/astral-sh/uv:0.10.4 /uv /uvx /bin/
|
|
ENV UV_COMPILE_BYTECODE=1 \
|
|
UV_LINK_MODE=copy \
|
|
UV_PYTHON_DOWNLOADS=never
|
|
|
|
WORKDIR /app
|
|
COPY pyproject.toml uv.lock README.md ./
|
|
RUN uv sync --frozen --no-dev --no-install-project
|
|
|
|
COPY src ./src
|
|
RUN uv sync --frozen --no-dev --no-editable
|
|
|
|
FROM python:3.12-slim AS runtime
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PULSECAST_ROOT=/app \
|
|
PULSECAST_ARTIFACTS=/app/artifacts \
|
|
PULSECAST_WEATHER=/app/artifacts \
|
|
PULSECAST_MODELS=/tmp/pulsecast/models \
|
|
PULSECAST_UPLOADS=/tmp/pulsecast/uploads \
|
|
PATH=/app/.venv/bin:$PATH
|
|
|
|
RUN groupadd --gid 10001 app \
|
|
&& useradd --uid 10001 --gid 10001 --home-dir /app --no-create-home \
|
|
--shell /usr/sbin/nologin app \
|
|
&& install -d -o 10001 -g 10001 -m 0755 \
|
|
/tmp/pulsecast /tmp/pulsecast/models /tmp/pulsecast/uploads
|
|
|
|
WORKDIR /app
|
|
COPY --chown=10001:10001 --from=builder /app/.venv /app/.venv
|
|
COPY --chown=10001:10001 artifacts ./artifacts
|
|
COPY --chown=10001:10001 main.py README.md model_card.md ./
|
|
|
|
USER 10001:10001
|
|
EXPOSE 8000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=2)"
|
|
|
|
CMD ["uvicorn", "pulsecast.server:app", "--host", "0.0.0.0", "--port", "8000"]
|