Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,14 @@ ar runtime apply -f runtime-build.yaml
# ar runtime cloud-build -f runtime-build.yaml
```

### Local runtime deploy skill

This local skill helps an agent prepare a project for AgentRun Runtime
deployment, including setup/start scripts, `agentruntime.yaml`, cloud build
configuration and the `ar runtime apply` flow.

[View the full skill](https://raw.githubusercontent.com/Serverless-Devs/agentrun-cli/main/skills/agentrun-cli-runtime-deploy/SKILL.md)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里现在链接的是 main 分支 raw 文件,无法控制版本,也不是可直接安装的发布包。建议在 .github/workflows/release.yml 中将 skills/run-your-agents/ 打成 run-your-agents-${VERSION}.zip 并上传到 GitHub Release(含 sha256),README/README_zh 改为版本化公网下载链接和安装步骤。


## Command groups

| Group | Alias | Purpose | Docs |
Expand Down
7 changes: 7 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ ar runtime apply -f runtime-build.yaml
# ar runtime cloud-build -f runtime-build.yaml
```

### 本地 Runtime 部署 Skill

这个本地 skill 用于让 Agent 帮项目准备 AgentRun Runtime 部署,包括启动脚本、
`agentruntime.yaml`、云构建配置和 `ar runtime apply` 流程。

[查看完整 skill](https://raw.githubusercontent.com/Serverless-Devs/agentrun-cli/main/skills/agentrun-cli-runtime-deploy/SKILL.md)

## 命令组总览

| 命令组 | 别名 | 用途 | 文档 |
Expand Down
69 changes: 69 additions & 0 deletions skills/agentrun-cli-runtime-deploy/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: agentrun-cli-runtime-deploy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 Skill 名称建议改成 run-your-agents,并同步目录名、frontmatter name、README 标题/链接和后续 Release asset 名称。现在的 agentrun-cli-runtime-deploy 更像实现细节,对外安装和传播时不够清晰。

description: 将当前项目整理并部署为 AgentRun Runtime,使用 agentrun-cli 的 ar runtime apply 与 cloudBuild 能力。Use when 用户要求把项目发布、部署、上线到 AgentRun runtime,提到 agentruntime.yaml、ar runtime apply、cloudBuild、docker-image-builder、AgentRun CLI runtime 部署,或需要补 scripts/setup.sh 和 scripts/start.sh。
---

# AgentRun CLI Runtime 部署

## 基本流程

1. 检查项目启动方式、依赖安装方式和运行端口,确定 runtime 名称、目标镜像和镜像仓库类型。
2. 补充可重复执行的 `scripts/setup.sh`。脚本在云端构建环境中运行,用于安装依赖、构建前端或准备运行目录。
3. 补充 `scripts/start.sh`。脚本必须读取环境变量 `PORT`,默认使用 `9000`,并绑定 `0.0.0.0`。
4. 编写 `agentruntime.yaml`,在 `spec.container.cloudBuild` 中声明云构建参数。
5. 运行 `ar runtime apply -f agentruntime.yaml --timeout 20m`。命令默认等待 runtime 和 endpoint 到终态。
6. 成功后从输出中的 `endpoints[].publicUrl` 获取公网访问地址,并按项目协议做访问验证。

## 脚本要求

`scripts/setup.sh` 应该可重复执行。只做构建期动作,例如安装依赖、编译前端、生成静态资源、准备运行目录。不要在脚本中写入密钥;密钥放入 `.env` 或运行环境变量,并确保不会进入 VCS。

`scripts/start.sh` 应该只负责启动服务。示例:

```bash
#!/usr/bin/env bash
set -euo pipefail

PORT="${PORT:-9000}"
HOST="${HOST:-0.0.0.0}"

exec your-server-command --host "$HOST" --port "$PORT"
```

## Runtime YAML 示例

```yaml
apiVersion: agentrun/v1
kind: AgentRuntime
metadata:
name: my-runtime
spec:
container:
image: registry.cn-hangzhou.aliyuncs.com/my-ns/my-agent:v1
command: ["bash", "-lc", "exec bash scripts/start.sh"]
cloudBuild:
dir: .
setupScript: scripts/setup.sh
timeoutMinutes: 20
cpu: 4
memory: 8192
port: 9000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要在 YAML 示例后补上 closing fence()。当前 head 里 ` yaml ` 没有关掉,后面的“镜像仓库”和“验证命令”都会被 Markdown 渲染进代码块。


`spec.container.cloudBuild` 会在部署前调用 docker-image-builder 云构建镜像;目标镜像就是 `spec.container.image`。

## 镜像仓库

- `cloudBuild` YAML 不支持 `registryMode` 字段;仅支持标准 OCI registry 模式。
- 如果设置了 `DOCKER_IMAGE_BUILDER_BINPATH`,agentrun-cli 会优先使用该路径的 docker-image-builder。
- 镜像仓库推送账号可通过 `DOCKER_IMAGE_BUILDER_USERNAME` 和 `DOCKER_IMAGE_BUILDER_PASSWORD` 提供;docker-image-builder 也兼容 `DOCKER_IMAGE_BUILDER_REGISTRY_USERNAME` 和 `DOCKER_IMAGE_BUILDER_REGISTRY_PASSWORD`。
- runtime 拉取私有镜像时,在 `spec.container.registryConfig.auth.userName` 和 `password` 中配置仓库账号密码;字段名必须是 `userName`,不是 `username`。
- 使用 ACR 企业版镜像时,可设置 `spec.container.imageRegistryType: ACREE` 和 `spec.container.acrInstanceId`。

## 验证命令

```bash
ar runtime render -f agentruntime.yaml
ar runtime apply -f agentruntime.yaml --timeout 20m
```

`render` 用于部署前校验和预览 SDK 输入;`apply` 默认等待 runtime 和 endpoint 到终态。
Loading