From 709131bcec6680b969096d3e894623a9188c7f04 Mon Sep 17 00:00:00 2001 From: David Hyrule Date: Mon, 29 Jun 2026 13:24:12 +0200 Subject: [PATCH] build: collector service Dockerfile (built on-host like knowledge-mcp) Container image for agent_core.collector; runs 'python -m agent_core.collector', set HYRULE_COLLECTOR_DATABASE_URL to postgresql+asyncpg in prod. Built on the loop host by the (forthcoming) ansible collector role via docker build, mirroring knowledge-mcp. Runtime validated via the TestClient suite; image build validated on the target host (no docker daemon in this dev env). Co-Authored-By: Claude Opus 4.8 --- .dockerignore | 11 +++++++++++ Dockerfile | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..27075e6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git/ +.venv/ +__pycache__/ +*.py[cod] +.mypy_cache/ +.ruff_cache/ +.pytest_cache/ +tests/ +dist/ +build/ +*.egg-info/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5d7aabe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,26 @@ +# Builds the agent-core trace collector service image. +# Built on the host by ansible/roles/collector (docker build), mirroring knowledge-mcp. +# Run: python -m agent_core.collector (FastAPI). Set HYRULE_COLLECTOR_DATABASE_URL to a +# postgresql+asyncpg URL in production. +FROM python:3.12-slim AS runtime + +ENV PYTHONUNBUFFERED=1 \ + UV_NO_CACHE=1 \ + PATH="/app/.venv/bin:${PATH}" \ + HYRULE_COLLECTOR_BIND=0.0.0.0 \ + HYRULE_COLLECTOR_PORT=8770 + +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +COPY --from=ghcr.io/astral-sh/uv:0.9.17 /uv /uvx /usr/local/bin/ + +WORKDIR /app +COPY pyproject.toml README.md ./ +COPY agent_core ./agent_core +RUN uv venv && uv pip install '.[collector]' + +EXPOSE 8770 +USER 65534:65534 +ENTRYPOINT ["python", "-m", "agent_core.collector"]