Workspace
Workspace is a remote development solution built on cloud-native principles, supporting remote connections via web and VSCode clients.
# Design Principles
Declarative
: Development environment based on the Dockerfile ecosystem, managed alongside codeFast Startup
: Code can be ready in seconds, even for large repositoriesOn-Demand Usage
: Development resources are acquired as needed and quickly reclaimed during idle times to avoid resource waste
# One-Click Creation of Development Environment
You can click the "Workspace" button in the branch page to create a development environment with a single click.
No configuration is required, and it will directly open a default development
environment using cnbcool/default-dev-env:latest
as the base image.
# Customizing the Development Environment
If you want to start a custom development environment when clicking the "Workspace" button on the branch page,
you can add a .ide/Dockerfile
file in the root directory of the repository. In the Dockerfile,
you can freely customize the development environment. When starting the development environment,
a custom image will be built using the .ide/Dockerfile
as the base image.
# .ide/Dockerfile
FROM node:20
# Install additional software as needed
# RUN apt-get update && apt-get install -y git
# Install code-server and commonly used VSCode extensions
RUN curl -fsSL https://code-server.dev/install.sh | sh \
&& code-server --install-extension redhat.vscode-yaml \
&& code-server --install-extension dbaeumer.vscode-eslint \
&& code-server --install-extension eamodio.gitlens \
&& code-server --install-extension tencent-cloud.coding-copilot \
&& echo done
# Install SSH service to support Remote-SSH access to the development environment from the VSCode client
RUN apt-get update && apt-get install -y wget unzip openssh-server
# Specify character set to support inputting Chinese characters in the command line
# (choose the appropriate character set as needed)
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8
# Customizing the Creation Process
If you want to use a custom YAML pipeline configuration when clicking the "Workspace" button on the branch page,
you can add a .cnb.yml
file in the root directory of the repository and add the following configuration:
# .cnb.yml
$:
# VSCode event: specifically for starting remote development from the page
vscode:
- docker:
# Use a custom image as the development environment
image: node:20
services:
- vscode
- docker
stages:
- name: ls
script: ls -al
# Customizing Resource Specifications
You can declare the required development resources using runner.cpus
,
with a maximum of 64 cores
and memory equal to cpus x 2(GB).
# .cnb.yml
$:
vscode:
- runner:
cpus: 64
docker:
build: .ide/Dockerfile
services:
- vscode
- docker
stages:
- name: ls
script: ls -al
# Customizing the Creation Timing
Using .cnb.yml
, you can automatically create a development environment when creating a new branch.
# .cnb.yml
# Match all branches
(**):
# Create a development environment when creating a branch
branch.create:
- name: vscode
services:
# Declare the use of the vscode service
- vscode
docker:
# Custom development environment
build: .ide/Dockerfile
wework:
title: Workspace
stages:
- name: Execute custom script
script:
- npm install
- npm run start