Overseas access: www.kdjingpai.com
Bookmark Us

CNB (Cloud Native Build) is a cloud native developer platform launched by Tencent, which is centered around the core concept of "everything is code" and is designed to help developers build software in a simpler and more powerful way. The platform defines and manages the entire process from development to build to test through a declarative YAML configuration file. This approach codifies the complex build process so that it can be managed by the version control system along with the project source code.CNB deeply integrates with the Docker ecosystem and utilizes container technology to ensure the consistency of the development, testing, and production environments, which fundamentally solves the problems caused by differences in the environments. In addition, the platform also provides a remote development solution based on "read-second cloning" technology, which can start a well-configured cloud development environment in seconds, greatly improving development efficiency.

Function List

  • Pipeline as Code: Use a simple, easy-to-understand YAML configuration file to define the entire build pipeline and incorporate it into Git for versioning.
  • Declarative build environment: Explicitly declaring the Docker images required for a build in a configuration file ensures that each build is executed in a pristine, consistent environment.
  • Declarative Construction of the Cache: Supports copy-on-write mode cache declaration, which effectively avoids cache read/write conflicts in concurrent build scenarios and improves build efficiency.
  • Docker as an execution environment: All build tasks run in the specified Docker container, utilizing Docker's sandboxing mechanism to ensure isolation and reliability of task execution.
  • Docker-based plugin ecosystem: Abstract general-purpose capabilities into Docker plugins and distribute them through Docker image repositories, where developers can easily share and reuse various build capabilities.
  • On-demand access to computing resources: Allow developers to declare the required CPU resources in a configuration file, and the platform will dynamically allocate up to 64 cores based on the declaration.
  • Remote workspace: Provides a cloud-based development environment solution that prepares a remote workspace in seconds at the click of a button and supports remote access for coding.
  • read-second cloning technology: Based on the OverlayFS implementation, even large code repositories of over 100GB can be cloned in seconds, allowing developers to get into coding quickly.

Using Help

At the heart of the CNB platform is its "everything is code" design philosophy. Almost everything a user does is done by editing a configuration file in YAML format. This file is usually placed in the root directory of the code repository, and is used to describe "what to do" and "under what circumstances".

Core concept: profiles

A most basic configuration file structure is as follows, which defines a configuration file in theNode.js 20A simple pipeline running in the environment consists of three steps: printing the version, installing the dependencies and running the tests.

main:
push:
- docker:
image: node:20
stages:
- node -v
- npm install
- npm test

After committing this file to your Git repository, CNB will automatically execute this pipeline.

Main Functional Configuration Details

1. Declarative build environment

You can specify different Docker environments for different tasks. cnb will automatically pull the corresponding Docker image and create a container to run your commands when the step is executed. This ensures that the environment is pure and consistent for each build.

For example, you can test the compatibility of projects under different Node.js versions in the same pipeline:

main:
push:
- stages:
- name: "在Node 20环境下运行"
image: node:20
script:
- node -v
- name: "在Node 21环境下运行"
image: node:21
script:
- node -v
  • name: Set a readable name for the step.
  • image: Specify the Docker image required to run this step.
  • script: Contains a list of commands to be executed.

2. Declarative construction of the cache

In order to speed up the build process, especially with a program likenpm installWith such a time-consuming dependency installation step, it's crucial to configure the cache.CNB's cache is declarative and supports thecopy-on-writemode, very suitable for concurrent scenarios, can effectively avoid cache read and write conflicts.

main:
push:
- docker:
image: node:20
volumes:
- node_modules:copy-on-write
stages:
- node -v
- npm install
- npm test
  • volumes: Declare the directory or file to be cached here.
  • node_modules:copy-on-write:: Indicates a change to thenode_modulesDirectory-enabled copy-on-write caching. When the cache does not exist, it writes normally; when the cache already exists, it creates a link to the cache, and the actual copy operation occurs only when the file is modified.

3. Allocation of high-performance resources on demand

If your build or test tasks require high computational performance (e.g. compilation, code analysis, etc.), you can request more CPU resources on demand.

main:
push:
- runner:
cpus: 64
docker:
image: node:20
stages:
- node -v
- npm install
- npm test
  • runner.cpus: Declare here the number of CPU cores you wish to allocate, up to 64 cores. The platform will dynamically fulfill your request based on resources.

4. Configuring remote development workspaces

This is a feature of CNB. You can define a remote development environment in a configuration file. When you need it, CNB will start a cloud development environment for you in seconds with full code and dependencies using "read-second cloning" technology.

$:
vscode:
- runner:
cpus: 64
services:
- vscode
docker:
image: node:20
volumes:
- node_modules:copy-on-write
stages:
- npm install
  • $Symbols are specific identifiers for remote workspaces.
  • Once the configuration is complete, click on the Cloud Native Development button for the corresponding repository on the CNB platform to launch it. The platform will pre-execute thestagescommands (such asnpm install), when you access it remotely, all the dependencies are ready and you can start coding straight away.

application scenario

  1. Automated CI/CD assembly line
    Configure automated build, test and deployment processes for projects. Developers simply push code to a Git repository, and CNB automates all subsequent processes, ensuring code quality and enabling rapid delivery.
  2. Unified Team Development Environment
    Remote workspace functionality ensures that all team members use the same development environment, avoiding the typical "works on my computer" problem and reducing the cost of configuring the environment for new members joining the project.
  3. Rapid development and review of large code repositories
    For projects with large code bases, the traditionalgit cloneIt can take tens of minutes or more. With CNB's read-second cloning technology, developers and reviewers can fetch code and launch a complete environment in seconds, dramatically improving the efficiency of code review and branch development.
  4. Build tasks that require high performance computing
    For projects that require large amounts of computing resources, such as C++ compilation, large-scale data processing or complex end-to-end testing, you can apply for HPC nodes on demand through CNB and use them on demand to save costs.

QA

  1. What kind of platform is CNB?
    CNB (Cloud Native Build) is a cloud native build platform for developers launched by Tencent Cloud. It helps developers automate the entire process of software development and provides an efficient remote development environment through the "everything is code" approach.
  2. What are the benefits of "everything is code"?
    It makes the build and deployment process transparent, traceable and easy to manage. The entire process is managed like code by a version control system (such as Git), any changes are documented, team members can collaborate on reviews and modifications, and can be easily reused and migrated.
  3. How does CNB's remote workspace start in seconds?
    It relies on a program calledgit-clone-yydsThe technology is based on the OverlayFS file system, which enables read-on-demand cloning of even 100GB repositories in seconds. Instead of downloading the entire code repository, it creates a view to the remote repository, enabling on-demand reads so that even 100GB repositories can be "cloned" and ready for workspaces in seconds.
  4. How is CNB different from traditional CI/CD tools?
    In addition to providing CI/CD capabilities, CNB emphasizes declarative management and consistency of environments and deeply integrates cloud-native development environments. It unifies the development environment and build pipeline to be defined with a set of declarative syntax, opening up the complete chain from development to build.
0Bookmarked
0kudos

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish