Deploying Node.js Projects with CelerBuild Using the Express Framework Example
This guide demonstrates how to deploy a Node.js application using CelerBuild, with Express framework as an example.
Prerequisites
1. System Prerequisites
Complete all Prerequisites setup steps.
2. Node.js Environment Setup
Installing Node.js and npm
macOS
# Using Homebrew
brew install node
# Verify installation
node --version
npm --version
Ubuntu/Debian
# Update package list
sudo apt update
# Install Node.js and npm
sudo apt install nodejs npm
# Verify installation
node --version
npm --version
CentOS/RHEL
# Install Node.js repository
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
# Install Node.js and npm
sudo yum install nodejs
# Verify installation
node --version
npm --version
3. PM2 Setup
Installing PM2
# Install PM2 globally
sudo npm install -g pm2
# Verify installation
pm2 --version
# Setup PM2 to start on system boot
pm2 startup
Branch Deployment (Development Environment)
1. Create Server Infrastructure
Create Server Cluster
- Navigate to
Global/Server Clusters
- Create a cluster named "example-nodejs-server-cluster(dev)"
Add Server
- Navigate to the
Global/Servers
section or go to theActions
menu of the newly createdexample-nodejs-server-cluster(dev)
and select "Servers" - Select cluster "example-nodejs-server-cluster(dev)"
- Fill in:
- Server Name
- Server IP
- SSH Port (default: 22)
2. Import Project Template
Download Template
- Download project template: celerbuild-example-nodejs-dev.yaml
- Template source: celerbuild-example-nodejs dev template (opens in a new tab)
Import Template
- Navigate to
Projects/Projects
- Click "Import YAML"
- Upload the downloaded template
Create Project
- Review and confirm project settings
- Click "Create Project" to finish
Note: This example uses Ubuntu system with
ubuntu
user. Please adjust the Deployment Configuration (Target Deployment Path, Target Repository Path, Deployment User, etc.) according to your actual environment.
3. Initiating Deployment
- Go to
Operations/Applications
- Select project "celerbuild-example-go-dev"
- Fill in Title and Description
- Click sync icon next to "Branch" and select latest dev branch
- Click "Submit Application"
For detailed steps, see Creating Deployment
4. Executing Deployment
- In
Operations/Tasks
, find your project task - Click "Deploy" button
- On the task page, click "Start Deploy"
- Monitor Server Status and Operation Logs
- If issues occur, check error messages and retry deployment after fixing
For detailed steps, see Execute Deployment Task
5. Verification
Access http://server:8082/version
(replace "server" with your server address)
# Example command
➜ ~ curl http://server:8082/version
# Expected response
{"version":"1.0.0"}
Note:
- Replace "server" with your actual server IP address
- A response similar to
{"version":"1.0.0"}
indicates successful deployment- If you cannot access the endpoint, check:
- Server firewall settings
- Port 8082 accessibility
- Application running status
Tag Deployment
1. Create Server Infrastructure
Create Server Cluster
- Navigate to
Global/Server Clusters
- Create a cluster named "example-nodejs-server-cluster(prod)"
Add Server
-
Navigate to the
Global/Servers
section or go to theActions
menu of the newly createdexample-nodejs-server-cluster(prod)
and select "Servers" -
Select cluster "example-nodejs-server-cluster(prod)"
-
Fill in:
- Server Name
- Server IP
- SSH Port (default: 22)
2. Import Project Template
Download Template
- Download project template: celerbuild-example-nodejs-prod.yaml
- Template source: celerbuild-example-nodejs prod template (opens in a new tab)
Import Template
- Navigate to
Projects/Projects
- Click "Import YAML"
- Upload the downloaded template
Create Project
- Review and confirm project settings
- Click "Create Project" to finish
3. Initiating Deployment
- Go to
Operations/Applications
- Select project "celerbuild-example-nodejs-prod" and Click "Apply Deploy"
- Fill in Title and Description
- Click sync icon next to "Tag" and select latest tag
- Click "Submit Application"
For detailed steps, see Creating Deployment
4. Executing Deployment
Follow the same steps as branch deployment execution.
5. Verification
Access http://server:8082/version
(replace "server" with your server address)
# Example command
➜ ~ curl http://server:8082/version
# Expected response
{"version":"1.0.0"}
Note:
- Replace "server" with your actual server IP address
- A response similar to
{"version":"1.0.0"}
indicates successful deployment- If you cannot access the endpoint, check:
- Server firewall settings
- Port 8082 accessibility
- Application running status
Rollback Operations
Note: Branch deployment rollback is not demonstrated here because the system only maintains the latest committed version. We'll demonstrate rollback using tag deployments instead.
Tag Deployment Rollback Example
1. Initial Deployment (v1.0.0)
For detailed deployment steps, refer to:
- Go to
Operations/Applications
- Select project "celerbuild-example-nodejs-prod"
- Fill in deployment information:
- Title: "Deploy v1.0.0"
- Description: "Initial deployment of v1.0.0"
- Click sync icon next to "Tag" and select "v1.0.0"
- Click "Submit Application"
- Execute deployment and verify:
curl http://server:8082/version
{"version":"1.0.0"}
2. Upgrade to v1.0.1
For detailed deployment steps, refer to:
- Go to
Operations/Applications
- Create new deployment
- Fill in deployment information:
- Title: "Upgrade to v1.0.1"
- Description: "Upgrading from v1.0.0 to v1.0.1"
- Select tag "v1.0.1"
- Submit and execute deployment
- Verify upgrade:
curl http://server:8082/version
{"version":"1.0.1"}
3. Rollback to v1.0.0
- In
Operations/Applications
, find your project - Click Actions (three dots) and select "Apply Rollback"
- Fill in rollback information:
- Title: "Rollback to v1.0.0"
- Description: "Rolling back from v1.0.1 to v1.0.0"
- Click sync icon next to "Select Rollback Tag"
- Select "v1.0.0" from the available tags
- Click "Submit Rollback"
4. Execute Rollback
- Go to
Operations/Tasks
- Find your rollback task
- Click "Rollback" in Actions
- Click "Start Rollback" on the task page
- Monitor Server Status and Operation Logs
- Verify rollback success:
curl http://server:8082/version
{"version":"1.0.0"}
For detailed rollback instructions, see:
Congratulations! You have successfully learned how to deploy Express Framework using CelerBuild Standard Edition, including branch deployment, tag deployment, and tag version rollback operations! 🎉