云原生构建(cnb.cool)插件:通过 isrvd 的 HTTP API 拉取镜像并 redeploy 指定容器。
container 存在/api/compose/docker/<container>/redeploy,传入 serviceName 和 image,服务端自动拉取镜像并重建/api/docker/image/prune 清理无用镜像通过 settings 传入,会以 PLUGIN_* 大写环境变量注入。
| 参数 | 必填 | 默认 | 说明 |
|---|---|---|---|
api_url | ✅ | - | API 基地址 |
api_token | ✅ | - | JWT Token,建议通过 secrets 注入 |
container | ✅ | - | 目标容器名(compose 项目名) |
registry | ✅ | - | 镜像仓库地址 |
image | ✅ | - | 镜像名(不含 registry 与 tag) |
tag | ❌ | latest | 镜像 tag |
service_name | ❌ | 同 container | compose 中的服务名 |
fail_if_missing | ❌ | true | 容器不存在时是否失败 |
image_prune | ❌ | true | 部署后是否清理无用镜像 |
main:
push:
- stages:
- name: deploy
image: docker.cnb.cool/bring/tools/isrvddeploy:latest
settings:
api_url: $DEPLOY_API_URL
api_token: $DEPLOY_API_TOKEN
container: <your-container>
service_name: <your-service> # 默认同 container
registry: <your-registry>
image: <your-image>
tag: latest
# fail_if_missing: true
# image_prune: true
项目使用 uv 管理依赖:
uv sync
uv run python main.py
运行前需要导出 PLUGIN_* 环境变量。
docker build -t docker.cnb.cool/bring/tools/isrvddeploy:latest .
docker run --rm \
-e PLUGIN_API_URL=<api-url> \
-e PLUGIN_API_TOKEN=<token> \
-e PLUGIN_CONTAINER=<container> \
-e PLUGIN_SERVICE_NAME=<service-name> \
-e PLUGIN_REGISTRY=<registry> \
-e PLUGIN_IMAGE=<image> \
-e PLUGIN_TAG=latest \
-e PLUGIN_IMAGE_PRUNE=true \
docker.cnb.cool/bring/tools/isrvddeploy:latest
.
├── main.py # 入口
├── plugin/
│ ├── config.py # 解析 PLUGIN_* 环境变量
│ ├── api.py # HTTP 客户端
│ ├── compose.py # compose YAML 解析与改写
│ └── deploy.py # 编排流程
├── Dockerfile
├── entrypoint.sh
└── pyproject.toml