429 字约 1 分钟
云原生构建基于 Docker 生态,对环境、缓存和插件进行了抽象。通过声明式语法,帮助开发者更高效地构建软件。
- 声明式:可编程、易分享的配置语法。
- 易管理:与代码同源管理,版本可追溯。
- 云原生:资源池化,降低基础设施运维负担。
构建环境声明
.cnb.yml
main:
push:
- docker:
image: node:20
stages:
- node -v
- npm install
- npm test构建缓存声明
.cnb.yml
main:
push:
- docker:
image: node:20
volumes:
- /root/.npm:copy-on-write
stages:
- node -v
- npm install
- npm testDocker 作为任务的运行环境
.cnb.yml
main:
push:
- stages:
- name: run with node 20
image: node:20
script: node -v
- name: run with node 21
image: node:21
script: node -v基于 Docker 生态的插件
.cnb.yml
main:
push:
- stages:
- name: hello world
image: cnbcool/hello-world按需获取计算资源
.cnb.yml
main:
push:
- runner:
cpus: 64
docker:
image: node:20
stages:
- node -v
- npm install
- npm test云原生开发
.cnb.yml
$:
vscode:
- runner:
cpus: 64
services:
- vscode
docker:
image: node:20
volumes:
- node_modules:copy-on-write
stages:
- npm install高性能
CPU 弹性伸缩
通过 runner.cpus 可按需申请 CPU 资源,最高 64 核。
秒级克隆
基于 OverlayFS 的 git-clone-yyds 可在数秒内完成代码准备,轻松支持 100GB+ 超大仓库。
缓存并发
copy-on-write 可实现缓存的写时复制,并发场景下无需担心缓存读写冲突。
.cnb.yml
main:
push:
- runner:
cpus: 64
docker:
image: node:20
volumes:
- /root/.npm:copy-on-write
stages:
- node -v
- npm install
- npm test