Preview Mode Only
About 554 wordsAbout 2 min
Preview Mode is a derivative capability of cloud-native development. In this mode, clicking the Cloud Native Development button opens the preview page directly instead of WebIDE, 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 WebIDE. Use Custom Buttons to create a Cloud Development button entry with WebIDE support.
- To use SSH connections, please install openssh in the image yourself.
- Preview Mode does not support proxy. The
$CNB_VSCODE_PROXY_URIenvironment variable is not available. Use standard Cloud Development Mode if proxy is needed.
How to Configure?
.cnb.yml
$:
vscode:
- docker:
build: .ide/Dockerfile
services:
- docker
- name: vscode
options:
onlyPreview: true
launch: node index.js
keepAliveTimeout: 10m
daemon: true
backup: true
stages:
- ls -alSee Parameter Details below for detailed explanations of each option.
Parameter Details
onlyPreview
- Type:
Boolean - Description: Whether to enable Preview Mode only.
- Effect: When set to
true, clicking the Cloud-Native Development button will open the preview page instead of WebIDE. To use SSH connections, install openssh in the image yourself.
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(10 minutes) - Description: The offline keep-alive time for the development environment. If no HTTP connection is detected within the specified duration, the environment will automatically shut down.
- Example:
7200000represents 2 hours.
You can write a number directly (milliseconds), or a string with units, such as 10m for 10 minutes. Supported units:
ms: milliseconds (default)s: secondsm: minutesh: hours
daemon
- Type:
Boolean - Default Value:
false - Description: Process startup mode:
true(Daemon mode): The service started by the launch command runs directly in the background.false(Non-daemon mode): Startup logs are visible. The process waits for the service to start and exit before continuing.
backup
- Type:
Boolean - Default Value:
false - Description: Whether to backup/restore user data (only effective in Preview Mode). When set to
true:- On startup: Restore previous user roaming data and uncommitted code changes.
- During runtime: Periodically backup uncommitted code changes.
- On shutdown: Backup user roaming data and uncommitted code changes.
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.
How to Use SSH Connections in Preview Mode?
Install openssh in your custom development environment. Configure it in .ide/Dockerfile as follows:
FROM node:20
RUN apt-get update && apt-get install -y git wget unzip openssh-server
ENV LANG C.UTF-8
ENV LANGUAGE C.UTF-8Once the preview workspace is ready, it opens the preview page directly without showing the client selection page. For client connections, find the entry under Avatar → My Cloud Native Development.