9805a865cb
CI / load-versions (pull_request) Successful in 17s
CI / push-validation (pull_request) Successful in 24s
CI / lint (pull_request) Successful in 33s
CI / build (pull_request) Successful in 30s
CI / quality (pull_request) Successful in 1m4s
CI / typecheck (pull_request) Successful in 1m13s
CI / security (pull_request) Successful in 1m9s
CI / helm (pull_request) Successful in 37s
CI / unit_tests (pull_request) Successful in 5m31s
CI / docker (pull_request) Successful in 2m24s
CI / integration_tests (pull_request) Successful in 8m50s
CI / coverage (pull_request) Successful in 11m58s
CI / status-check (pull_request) Successful in 3s
83 lines
3.0 KiB
Docker
83 lines
3.0 KiB
Docker
# syntax=docker/dockerfile:1
|
|
# CleverAgents Server Dockerfile
|
|
# Multi-stage build for the ASGI server deployment.
|
|
# See k8s/README.md for Kubernetes deployment instructions.
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 1: Build
|
|
# ---------------------------------------------------------------------------
|
|
# NOTE: Base images are pinned by tag (not by digest) for readability and
|
|
# ease of updates. Digest pinning provides stronger reproducibility but
|
|
# complicates routine version bumps. For production supply-chain security,
|
|
# consider switching to digest pinning or using a verified image registry.
|
|
FROM python:3.13-slim AS builder
|
|
|
|
# Install build dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install uv for fast dependency resolution
|
|
COPY --from=ghcr.io/astral-sh/uv:0.8.0 /uv /usr/local/bin/uv
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy dependency manifests first to leverage Docker layer caching.
|
|
# The expensive dependency installation step is only re-executed when
|
|
# pyproject.toml or uv.lock change, not on every source code change.
|
|
COPY pyproject.toml uv.lock ./
|
|
|
|
# Install build tool (separate layer for better caching) — this layer is
|
|
# cached as long as pyproject.toml and uv.lock remain unchanged.
|
|
RUN uv pip install --system build
|
|
|
|
# Copy remaining source files needed for the wheel build.
|
|
COPY README.md ./
|
|
COPY src/ ./src/
|
|
|
|
# Build wheel
|
|
RUN python -m build --wheel --outdir /dist
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Stage 2: Runtime
|
|
# ---------------------------------------------------------------------------
|
|
FROM python:3.13-slim
|
|
|
|
# Apply currently available security fixes from the base distribution before
|
|
# scanning the runtime image.
|
|
RUN apt-get update && apt-get upgrade -y --no-install-recommends \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create non-root user (uid 1000 per spec)
|
|
RUN useradd -m -u 1000 appuser
|
|
|
|
# Install uv temporarily for fast package installation, then remove it
|
|
# to reduce attack surface in the runtime image.
|
|
COPY --from=ghcr.io/astral-sh/uv:0.8.0 /uv /usr/local/bin/uv
|
|
|
|
# Install the built wheel (includes uvicorn as a runtime dependency)
|
|
COPY --from=builder /dist/*.whl /tmp/
|
|
RUN uv pip install --system --no-cache /tmp/*.whl && \
|
|
rm -rf /tmp/* && \
|
|
rm /usr/local/bin/uv
|
|
|
|
# Create writable directories for runtime data
|
|
RUN mkdir -p /app/data && chown appuser:appuser /app/data
|
|
|
|
# Switch to non-root user
|
|
USER appuser
|
|
WORKDIR /app
|
|
|
|
# Expose the default server port
|
|
EXPOSE 8000
|
|
|
|
# Health check against the /health endpoint
|
|
# Note: Health checking in Kubernetes is handled by liveness/readiness
|
|
# probes configured in the Helm chart (k8s/values.yaml).
|
|
|
|
# Run the ASGI server through the project CLI entrypoint.
|
|
# This aligns with the specification's deployment contract:
|
|
# `python -m cleveragents`.
|
|
ENTRYPOINT ["python", "-m", "cleveragents"]
|
|
CMD ["server", "serve", "--app", "cleveragents.a2a.asgi:app", "--host", "0.0.0.0", "--port", "8000"]
|