Template Variables & Mode Switching
The configuration file cloudbaserc.json
supports template variables and allows switching variables across multiple modes.
Template Variables
- Step 1: Create cloudbaserc.json and .env files in the project root directory.
.
├─cloudbaserc.json
├─.env
- Step 2: Add variables in the .env file.
ENV_ID=pro-123
DB_NAME=pro_user
- Step 3: Inject template variables via
env
in the cloudbaserc.json file.
{
"version": "2.0",
"envId": "{{env.ENV_ID}}",
"framework": {
"name": "node-capp",
"plugins": {
"node": {
"use": "@cloudbase/framework-plugin-node",
"inputs": {
"name": "node-capp",
"path": "/node-capp",
"platform": "container",
"containerOptions": {
"envVariables": {
"env": "{{env.ENV_ID}}",
"db": "{{env.DB_NAME}}"
}
}
}
}
}
}
}
> Note: version
must be greater than 2.0
- Step 4: One-click application deployment
cloudbase framework deploy
Mode Switching
Assuming you have completed the configuration of the above template variables
Step 1: Additionally create the .env.dev file in the project root directory.
.
├─cloudbaserc.json
├─.env
├─.env.dev
- Step 2: Add variables in the .env.dev file.
ENV_ID=dev-123
DB_NAME=dev_user
- Step 3: Specify the mode using
--mode
when deploying applications.
cloudbase framework deploy --mode dev