Files
cleveragents-core/docker/Dockerfile
freemo e13308b322 feat(server): integrate LangGraph Platform with RemoteGraph for server execution
Implement the server application module (ADR-048) with:

- FastAPI application factory (app.py) exposing the A2A JSON-RPC 2.0
  endpoint as the sole client-facing interface. Routes: POST /a2a
  (JSON-RPC dispatch), GET /.well-known/agent.json (Agent Card), and
  GET /health (container orchestration).

- RemoteGraph adapter (remote_graph.py) for invoking actor graphs
  via LangGraph Platform. Each actor graph deploys as a separate
  RemoteGraph enabling independent scaling. Includes health tracking,
  invocation counting, and a RemoteGraphRegistry for managing
  multiple graph deployments.

- Database configuration (database.py) supporting PostgreSQL for
  production and SQLite for development. Config-driven via
  CLEVERAGENTS_DATABASE_URL and CLEVERAGENTS_SERVER_ENV environment
  variables with validated Pydantic settings model.

- Docker deployment (docker/Dockerfile + docker-compose.yml) with
  multi-stage build, non-root user, health checks, and PostgreSQL
  service.

- FastAPI dependency added to pyproject.toml.

- 26 Behave BDD scenarios covering app factory, A2A dispatch, Agent
  Card, health endpoint, RemoteGraph config/adapter/registry, and
  database configuration.

- 10 Robot Framework integration tests with helper script verifying
  end-to-end server functionality.

ISSUES CLOSED: #693
2026-03-12 03:05:00 +00:00

59 lines
1.7 KiB
Docker

# CleverAgents Server — production container image (ADR-048)
#
# Multi-stage build:
# 1. Builder stage — installs dependencies into a venv
# 2. Runtime stage — copies the venv and source for minimal image size
#
# Usage:
# docker build -f docker/Dockerfile -t cleveragents-server .
# docker run -p 8000:8000 cleveragents-server
# ---------------------------------------------------------------------------
# Builder
# ---------------------------------------------------------------------------
FROM python:3.13-slim AS builder
WORKDIR /build
# Install build dependencies
RUN pip install --no-cache-dir hatchling>=1.21.0
# Copy dependency metadata first for layer caching
COPY pyproject.toml README.md ./
COPY src/ src/
# Build wheel
RUN pip install --no-cache-dir --prefix=/install .
# ---------------------------------------------------------------------------
# Runtime
# ---------------------------------------------------------------------------
FROM python:3.13-slim AS runtime
# Security: run as non-root
RUN groupadd --gid 1000 cleveragents \
&& useradd --uid 1000 --gid cleveragents --shell /bin/bash --create-home cleveragents
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /install /usr/local
# Copy source (for editable installs / debugging)
COPY src/ src/
# Create data directory
RUN mkdir -p /app/.cleveragents && chown -R cleveragents:cleveragents /app
USER cleveragents
# Server port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" || exit 1
# Default command — run the server
CMD ["uvicorn", "cleveragents.server.app:app", "--host", "0.0.0.0", "--port", "8000"]