Skip to content

Agent Mesh

1.4 KB
Raw Blame
# The Python SDK with its example programs, as the testnet canaries run them:
# `python examples/agent.py [url]` joins as an agent that accepts A2A
# requests, `python examples/call.py [peer] <service> <tool|path> [args]`
# calls a service or an agent, and `examples/a2a_agent.py` and
# `examples/a2a_call.py` do the same with the official A2A SDK, which the
# `examples` extra installs. fastecdsa, a py-libp2p dependency, builds from
# source against GMP, so the build stage carries a compiler and the final
# image only libgmp10.

# Stage 1: Build
FROM python:3.12-slim-bookworm@sha256:34386ef0cb081344d7ec1c103ba398e6e9f64e9ab3a1509accc92a4e24a07258 AS builder
RUN apt-get update && apt-get install -y --no-install-recommends gcc libgmp-dev python3-dev && rm -rf /var/lib/apt/lists/*
COPY sdk/python /src
RUN python -m venv /opt/venv && /opt/venv/bin/pip install --no-cache-dir '/src[examples]'

# Stage 2: Final
FROM python:3.12-slim-bookworm@sha256:34386ef0cb081344d7ec1c103ba398e6e9f64e9ab3a1509accc92a4e24a07258
RUN apt-get update && apt-get install -y --no-install-recommends libgmp10 && rm -rf /var/lib/apt/lists/* \
    && groupadd --gid 65532 nonroot && useradd --uid 65532 --gid nonroot --create-home nonroot
WORKDIR /app
COPY --from=builder --chown=nonroot:nonroot /opt/venv /opt/venv
COPY --chown=nonroot:nonroot sdk/python/examples ./examples
USER nonroot:nonroot
ENV PATH=/opt/venv/bin:$PATH
ENTRYPOINT ["python"]
CMD ["examples/agent.py"]