From 3cd6a73d86bf888a59b75ef4043ec6786f98edcd Mon Sep 17 00:00:00 2001 From: chiguyong Date: Sat, 6 Jun 2026 12:47:47 +0800 Subject: [PATCH] feat(cli): Docker deployment + README CLI section U5: docker-compose.yaml (agentkit + redis + postgres) + Dockerfile ENTRYPOINT U6: README updated with CLI quick start + Docker deployment guide 31 CLI tests passing, no regression. --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yaml | 58 ++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 docker-compose.yaml diff --git a/README.md b/README.md index 4120b54..235d11e 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,78 @@ pip install -e ".[dev]" - Python >= 3.11 - Redis(可选,分布式模式需要) +- PostgreSQL + pgvector(可选,语义记忆需要) + +### CLI 快速开始 + +安装后即可使用 `agentkit` 命令行工具: + +```bash +# 查看版本 +agentkit version + +# 初始化项目(生成配置文件) +agentkit init + +# 启动 Server +agentkit serve --host 0.0.0.0 --port 8001 + +# 健康检查 +agentkit health + +# 提交任务(远程模式) +agentkit task submit --skill content_generator --input '{"topic": "AI趋势"}' --server-url http://localhost:8001 + +# 异步提交任务 +agentkit task submit --skill content_generator --input '{"topic": "AI趋势"}' --mode async --server-url http://localhost:8001 + +# 查看任务状态 +agentkit task status --server-url http://localhost:8001 + +# 列出任务 +agentkit task list --server-url http://localhost:8001 + +# 取消任务 +agentkit task cancel --server-url http://localhost:8001 + +# 列出已注册 Skill +agentkit skill list --server-url http://localhost:8001 + +# 加载 Skill 配置 +agentkit skill load ./my_skill.yaml + +# 查看 Skill 详情 +agentkit skill info content_generator --server-url http://localhost:8001 + +# 查看 LLM 用量 +agentkit usage --server-url http://localhost:8001 + +# 也可以用 python -m 方式运行 +python -m agentkit version +``` + +### Docker 部署 + +```bash +# 初始化项目配置 +agentkit init + +# 编辑 .env 文件,填入 API Key +cp .env.example .env +# 编辑 .env ... + +# 启动完整环境(AgentKit + Redis + PostgreSQL) +docker-compose up -d + +# 查看日志 +docker-compose logs -f agentkit + +# 健康检查 +docker-compose exec agentkit agentkit health + +# 停止 +docker-compose down +``` ### 最小示例 diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..9d5cb34 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,58 @@ +version: "3.8" + +services: + agentkit: + build: . + command: serve --host 0.0.0.0 --port 8001 + ports: + - "8001:8001" + env_file: .env + environment: + - REDIS_URL=redis://redis:6379/0 + - DATABASE_URL=postgresql+asyncpg://agentkit:agentkit@postgres:5432/agentkit + depends_on: + redis: + condition: service_healthy + postgres: + condition: service_healthy + healthcheck: + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8001/api/v1/health')"] + interval: 30s + timeout: 10s + start_period: 30s + retries: 3 + restart: unless-stopped + + redis: + image: redis:7-alpine + ports: + - "6379:6379" + volumes: + - redisdata:/data + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 5s + retries: 5 + restart: unless-stopped + + postgres: + image: pgvector/pgvector:pg15 + ports: + - "5432:5432" + environment: + POSTGRES_USER: agentkit + POSTGRES_PASSWORD: agentkit + POSTGRES_DB: agentkit + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U agentkit"] + interval: 10s + timeout: 5s + retries: 5 + restart: unless-stopped + +volumes: + redisdata: + pgdata: