Introduction to Cloud Native Build
About 400 wordsAbout 1 min
Cloud Native Build is based on the Docker ecosystem, with abstractions for environments, caches, and plugins through declarative syntax that lets you build software efficiently.
- Declarative: Programmable, easy-to-share configuration syntax
- Easy to manage: Source-controlled alongside code, version-tracked
- Cloud Native: Resource pooling that reduces infrastructure operational costs
Build Environment & Cache
In the declarative configuration, specify the build environment via docker.image and declare cache directories via volumes:
main:
push:
- docker:
image: node:20
volumes:
- /root/.npm:copy-on-write
stages:
- node -v
- npm install
- npm testDocker as Task Execution Environment
Each stage can use a different image, suitable for scenarios requiring multiple languages or versions:
main:
push:
- stages:
- name: run with node 20
image: node:20
script: node -v
- name: run with node 21
image: node:21
script: node -vDocker Ecosystem Based Plugins
Extend build capabilities with community or official plugins:
main:
push:
- stages:
- name: hello world
image: cnbcool/hello-worldOn-demand Computing Resources
Request higher-spec compute resources via runner.cpus, up to 64 cores:
main:
push:
- runner:
cpus: 64
docker:
image: node:20
volumes:
- /root/.npm:copy-on-write
stages:
- node -v
- npm install
- npm testWorkspaces
Remote development environments are also declared using .cnb.yml:
$:
vscode:
- runner:
cpus: 64
services:
- vscode
docker:
image: node:20
volumes:
- node_modules:copy-on-write
stages:
- npm installHigh Performance
Elastic CPU Scaling
Through runner.cpus, you can request CPU resources on demand, up to 64 cores.
Second-level Cloning
Based on OverlayFS, git-clone-yyds can complete code preparation in seconds, easily supporting 100GB+ large repositories.
Cross-Node Caching
When you need to share caches across nodes, use the docker:cache built-in task to build the cache as a Docker image:
main:
push:
- stages:
- name: build cache
type: docker:cache
options:
targets:
- name: npm_cache
image: ${CNB_DOCKER_REGISTRY}/${CNB_REPO_SLUG_LOWERCASE}/npm-cache
dockerfile: Dockerfile.cacheConcurrent Caching
copy-on-write enables copy-on-write for caches, eliminating cache read-write conflicts in concurrent scenarios.