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.
This commit is contained in:
chiguyong 2026-06-06 12:47:47 +08:00
parent b2709da08b
commit 3cd6a73d86
2 changed files with 130 additions and 0 deletions

View File

@ -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 <task_id> --server-url http://localhost:8001
# 列出任务
agentkit task list --server-url http://localhost:8001
# 取消任务
agentkit task cancel <task_id> --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
```
### 最小示例

58
docker-compose.yaml Normal file
View File

@ -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: