initial a2a-pack
This commit is contained in:
14
a2a_pack/cli/templates/Dockerfile.tmpl
Normal file
14
a2a_pack/cli/templates/Dockerfile.tmpl
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM registry.127-0-0-1.nip.io/a2a/a2a-pack-base:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . .
|
||||
|
||||
ENV A2A_ENTRYPOINT={{ entrypoint }}
|
||||
ENV PORT=8000
|
||||
EXPOSE 8000
|
||||
|
||||
CMD a2a run --entrypoint "$A2A_ENTRYPOINT" --host 0.0.0.0 --port 8000
|
||||
8
a2a_pack/cli/templates/a2a.yaml.tmpl
Normal file
8
a2a_pack/cli/templates/a2a.yaml.tmpl
Normal file
@@ -0,0 +1,8 @@
|
||||
# Project identity for `a2a deploy`. Most metadata (resources, scopes,
|
||||
# secrets, workspace, etc.) lives on the Python class — this file only
|
||||
# tells the CLI how to find it.
|
||||
name: {{ name }}
|
||||
version: 0.1.0
|
||||
entrypoint: agent:{{ class_name }}
|
||||
expose:
|
||||
public: true
|
||||
24
a2a_pack/cli/templates/agent.py.tmpl
Normal file
24
a2a_pack/cli/templates/agent.py.tmpl
Normal file
@@ -0,0 +1,24 @@
|
||||
"""{{ name }} agent."""
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
from a2a_pack import A2AAgent, NoAuth, RunContext, skill
|
||||
|
||||
|
||||
class {{ class_name }}Config(BaseModel):
|
||||
pass
|
||||
|
||||
|
||||
class {{ class_name }}(A2AAgent[{{ class_name }}Config, NoAuth]):
|
||||
name = "{{ name }}"
|
||||
description = "{{ description }}"
|
||||
version = "0.1.0"
|
||||
|
||||
config_model = {{ class_name }}Config
|
||||
auth_model = NoAuth
|
||||
|
||||
@skill(description="Say hello")
|
||||
async def hello(self, ctx: RunContext[NoAuth], who: str = "world") -> str:
|
||||
await ctx.emit_progress(f"greeting {who}")
|
||||
return f"hello {who}"
|
||||
71
a2a_pack/cli/templates/deployment.yaml.tmpl
Normal file
71
a2a_pack/cli/templates/deployment.yaml.tmpl
Normal file
@@ -0,0 +1,71 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ name }}
|
||||
namespace: agents
|
||||
labels:
|
||||
app: {{ name }}
|
||||
a2a/managed-by: control-plane
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ name }}
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{ name }}
|
||||
spec:
|
||||
containers:
|
||||
- name: agent
|
||||
# tag is rewritten by the build workflow on every push
|
||||
image: registry.127-0-0-1.nip.io/agents/{{ name }}:latest
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
name: http
|
||||
readinessProbe:
|
||||
httpGet: {path: /healthz, port: 8000}
|
||||
initialDelaySeconds: 2
|
||||
periodSeconds: 5
|
||||
livenessProbe:
|
||||
httpGet: {path: /healthz, port: 8000}
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 15
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 256Mi}
|
||||
limits: {cpu: 200m, memory: 256Mi}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ name }}
|
||||
namespace: agents
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: {{ name }}
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 8000
|
||||
---
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ name }}
|
||||
namespace: agents
|
||||
spec:
|
||||
rules:
|
||||
- host: {{ name }}.127-0-0-1.nip.io
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: {{ name }}
|
||||
port:
|
||||
number: 80
|
||||
7
a2a_pack/cli/templates/dockerignore.tmpl
Normal file
7
a2a_pack/cli/templates/dockerignore.tmpl
Normal file
@@ -0,0 +1,7 @@
|
||||
__pycache__
|
||||
*.pyc
|
||||
.venv
|
||||
.git
|
||||
.pytest_cache
|
||||
.mypy_cache
|
||||
node_modules
|
||||
1
a2a_pack/cli/templates/requirements.txt.tmpl
Normal file
1
a2a_pack/cli/templates/requirements.txt.tmpl
Normal file
@@ -0,0 +1 @@
|
||||
# add agent-specific deps here; a2a-pack is auto-installed by the deploy build
|
||||
35
a2a_pack/cli/templates/workflow.yml.tmpl
Normal file
35
a2a_pack/cli/templates/workflow.yml.tmpl
Normal file
@@ -0,0 +1,35 @@
|
||||
name: build
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths-ignore:
|
||||
- 'deploy/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: build image
|
||||
run: |
|
||||
IMG=registry.127-0-0-1.nip.io/agents/{{ name }}
|
||||
docker build -t "$IMG:$GITHUB_SHA" -t "$IMG:latest" .
|
||||
docker push "$IMG:$GITHUB_SHA"
|
||||
docker push "$IMG:latest"
|
||||
|
||||
- name: bump deploy manifest
|
||||
run: |
|
||||
IMG=registry.127-0-0-1.nip.io/agents/{{ name }}
|
||||
sed -i "s|image: $IMG:.*|image: $IMG:$GITHUB_SHA|" deploy/20-deployment.yaml
|
||||
git config user.email "ci@a2a.local"
|
||||
git config user.name "ci"
|
||||
git add deploy/20-deployment.yaml
|
||||
if git diff --staged --quiet; then
|
||||
echo "no manifest changes"
|
||||
else
|
||||
git commit -m "ci: bump image to $GITHUB_SHA"
|
||||
git push "http://gitea_admin:gitea_admin@gitea-http.gitea.svc.cluster.local:3000/gitea_admin/{{ name }}.git" HEAD:main
|
||||
fi
|
||||
Reference in New Issue
Block a user