Custom Development Environment
About 320 wordsAbout 1 min
Specify Development Environment Using Docker Image
You can specify the development environment image by writing a remote development pipeline in .cnb.yml
and setting pipeline.docker.image
.
# .cnb.yml
$:
vscode:
- docker:
# Specify development environment image, can be any accessible image
image: node:20
services:
- vscode
- docker
# Tasks to execute after development environment starts
stages:
- name: ls
script: ls -al
Customize Development Environment Using Dockerfile
If specifying an image cannot meet your requirements, you can write your own Dockerfile
to customize the development environment.
Add a .ide/Dockerfile
file in the repository root directory, and freely customize your development environment in the Dockerfile.
When starting the development environment, it will prioritize using .ide/Dockerfile
to build an image as the base image for the development environment.
Note: In the default pipeline for starting the development environment, if both default image
and .ide/Dockerfile
are configured, and if .ide/Dockerfile
doesn't exist or fails to build, it will use the default image
as the base image for the development environment. If you find the started environment doesn't meet expectations, you can check the build logs in the prepare
stage to see if .ide/Dockerfile
built successfully.
# .ide/Dockerfile
FROM node:20
# Install other software as needed
# RUN apt-get update && apt-get install -y git
# Install code-server and common 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 waderyan.gitblame \
&& code-server --install-extension mhutchie.git-graph \
&& code-server --install-extension donjayamanne.githistory \
&& code-server --install-extension tencent-cloud.coding-copilot \
&& echo done
# Install SSH service to support VSCode and other clients accessing the development environment via Remote-SSH
RUN apt-get update && apt-get install -y wget unzip openssh-server
# Specify character set to support Chinese input in command line (choose character set as needed)
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8