Preview Mode Only
About 573 wordsAbout 2 min
Cloud Development Preview Mode is a derivative capability of cloud-native development. In this mode, clicking the Cloud Native Development button will not open the WebIDE but will directly start and open the preview page, providing a faster preview experience.
Notes
- This feature is in beta; related configurations and usage methods are subject to change in the future.
- Preview Mode does not support opening WebIDE or SSH. You can use Custom Buttons to define a button entry that opens Cloud Development Mode (which supports WebIDE).
How to Configure?
# .cnb.yml
$:
vscode:
- docker:
build: .ide/Dockerfile
services:
# If the launch command requires using docker or docker compose commands, the docker service must be listed before the vscode service
- docker
- name: vscode
options:
# Enable Preview Mode
onlyPreview: true
# Command to start the business service port; the port must be started on 8686
launch: node index.js
# Keep-alive timeout in milliseconds. Default is 10 minutes (no heartbeat detected, i.e., no HTTP connection detected in the dev environment) before shutting down the dev environment.
keepAliveTimeout: 3600000
# Whether to use daemon mode. Default is false (non-daemon mode).
# true: Start in daemon mode, meaning the launch command starts the preview business service directly in the background.
# false: Start in non-daemon mode. When executing the launch command to start the preview business service, logs are visible, and the process waits for the launch command to complete and exit proactively before continuing subsequent steps.
# Recommended to set to false, allowing users to implement their own logic for the service to run in the background after successful startup, enabling viewing of business startup logs for easier troubleshooting.
daemon: true
# Tasks executed after the development environment starts
stages:
- name: ls
script: ls -alParameter Details
onlyPreview
- Type:
Boolean - Description: Whether to enable Preview Mode only.
- Effect: When set to
true, clicking the Cloud-Native Development button will directly open the preview page. Starting WebIDE and SSH services is not supported in this mode, meaning you cannot open WebIDE or establish an SSH connection.
launch
- Type:
String - Description: The command to start the business service.
- Note: The business service must be started on port
8686. - Examples:
node index.js,npm start,python app.py, etc.
keepAliveTimeout
- Type:
Number|String(unit defaults to: milliseconds) - Default Value:
600000(ms, 10 minutes) - Description: The keep-alive timeout for the development environment. If no HTTP connection is detected within the development environment for the specified duration, the environment will automatically shut down.
- Example:
3600000represents 1 hour.
You can directly write a number to indicate the duration in milliseconds, or use a string format with units, such as 10m for 10 minutes. The following units are supported:
ms: milliseconds (default)s: secondsm: minutesh: hours
daemon
- Type:
Boolean - Default Value:
false - Description: Configuration for the process startup mode:
true(Daemon mode): The service started by the launch command runs directly in the background.false(Non-daemon mode): The startup logs of the launch command are visible. The process waits for the service to start successfully and exit proactively before continuing subsequent steps.
Usage Process
- Create a
.cnb.ymlfile in the project root directory. - Configure it according to the example above.
- Ensure the business service listens on port
8686. - Click the Cloud-Native Development button.
- The system will automatically start the development environment and open the preview page.