Deploying Go Projects with CelerBuild Pro Using the Gin Framework Example
This guide demonstrates how to deploy a Go project using CelerBuild Pro Version, covering branch deployment, tag deployment, and tag version rollback operations with multiple roles. We'll use the celerbuild-example-go (opens in a new tab) project built with the Gin framework.
Note This tutorial uses the Pro Version. For Standard Version features, please refer to the Standard Version Guide.
Prerequisites
1. System Prerequisites
Complete all Prerequisites setup steps
2. Go Environment Setup
Installing Go
macOS
# Using Homebrew
brew install go
# Verify installation
go version
Ubuntu/Debian
# Add the repository
sudo add-apt-repository ppa:longsleep/golang-backports
sudo apt update
# Install Go
sudo apt install golang-go
# Verify installation
go version
CentOS/RHEL
# Install Go
sudo yum install epel-release
sudo yum install golang
# Verify installation
go version
Environment Variables
Add these lines to your shell profile (~/.bashrc, ~/.zshrc, etc.):
# Go environment variables
export GOPATH=$HOME/go
export GOROOT=/usr/local/go # This might vary based on installation method
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
Note:
- The deployment process uses makefile (opens in a new tab) for testing and building
- Minimum Go version required: 1.16 or later
- After setting environment variables, run
source ~/.bashrc
(or your shell profile) to apply changes
3. Build Tools Setup
Installing Make Tool
macOS
# make is included in Command Line Tools
xcode-select --install
# Verify installation
make --version
Ubuntu/Debian
# make is usually pre-installed, if not:
sudo apt update
sudo apt install make
# Verify installation
make --version
CentOS/RHEL
# make is usually pre-installed, if not:
sudo yum install make
# Verify installation
make --version
Note:
- Most Unix-like systems (macOS, Linux) come with
make
pre-installed- For macOS, if
make
is not found, installing Command Line Tools will include it- The deployment process requires
make
for building and packaging operations
Role Setup and Permissions
1. Team Structure
-
Leader (Tom): Admin + Space Owner + Project Owner
- Username: tom
- Email: [email protected]
-
Developer A (Jerry): Project Master
- Username: jerry
- Email: [email protected]
-
Developer B (Bob): Developer
- Username: bob
- Email: [email protected]
2. Initial Setup Process (by Tom)
2.1 Create Users
- Navigate to
Base/Users
- Create team members' accounts:
Create Jerry's account:
- Username: jerry
- Email: [email protected]
Create Bob's account:
- Username: bob
- Email: [email protected]
Note:
- By default, there is an admin user
- You can promote yourself (Tom) to admin and then delete the default admin user
- At least one admin user must exist in the system at all times
2.2 Create Space
- Navigate to
Global/Spaces
- Create new space:
- Name: go-example-space
2.3 Import Space Members
Import members from the global user pool to ensure team members have access and can collaborate.
- Locate the space you just added.
- In the corresponding Actions menu, find and click the Members button.
- Click on Import Members to proceed with the import.
2.4 Set Space Owner
Designate a member as the space owner, responsible for managing resources and permissions within the space. In this example, set Tom as the Space Owner.
- Locate the user named Tom.
- In the corresponding Actions menu, click Edit.
- Change his permissions to Owner.
3. Create Server Infrastructure
3.1 Create Server Clusters
- Navigate to
Global/Server Clusters
- Create development cluster:
- Click "New"
- Fill in cluster details:
- Name: pro-example-go-server-cluster(dev)
- Select Environment: dev
- Select Status: Available
- Click "Create"
- Create production cluster:
- Click "New"
- Fill in cluster details:
- Name: pro-example-go-server-cluster(prod)
- Select Environment: prod
- Select Status: Available
- Click "Create"
3.2 Add Servers
- Navigate to
Global/Servers
- Add development server:
- Click "New"
- Fill in server details:
- Select cluster: pro-example-go-server-cluster(dev)
- Server Name: pro-go-dev-server-1
- Server IP: Your server IP
- SSH Port: Your SSH port (default: 22)
- Click "Create"
- Add production server:
- Click "New"
- Fill in server details:
- Select cluster: pro-example-go-server-cluster(prod)
- Server Name: pro-go-prod-server-1
- Server IP: Your server IP
- SSH Port: Your SSH port (default: 22)
- Click "Create"
Note:
- Server names are prefixed with "pro-" to distinguish from standard version
- Ensure SSH access is properly configured for each server
- Multiple servers can be added to each cluster if needed
3.3 Import Space Server Clusters
- Locate the left navigation and select
Space Resources
, then chooseServer Cluster
. - Switch to the space you created earlier,
go-example-space
. - Click the "Import Server Clusters" button and select the existing server cluster from Global to import.
Once imported, the space server cluster can be used as a selectable server cluster list for projects within the current space.
4. Create Projects and Import Project Members
4.1 Development Project
Download Template
- Download project template: celerbuild-example-go-dev.yaml
- Template source: celerbuild-example-go dev template (opens in a new tab)
Import Template
The imported project name, Space, and server cluster need to be changed, and others need to be modified according to your own requirements
- Navigate to
Projects/Projects
- Click "Import YAML"
- Upload the downloaded template
- Configure development project:
- Project name: "pro-celerbuild-example-go-dev"
- Select cluster: "pro-example-go-server-cluster(dev)"
- The development environment can choose not to enable deployment approval (It is off by default)
- Click "Create Project"
Import Project Members
- In the newly created project, find
Members
under theActions
menu and click to import project members. - Click "Import Members" to add project members.
- After importing, assign specific roles to the members:
- Set Tom as the Project Owner
- Set Jerry as the Project Master
- Set Bob as the Developer
4.2 Production Project
Download Template
- Download project template: celerbuild-example-go-prod.yaml
- Template source: celerbuild-example-go prod template (opens in a new tab)
Import Template
The imported project name and server cluster need to be changed, and others need to be modified according to your own requirements
- Navigate to
Projects/Projects
- Click "Import YAML"
- Upload the downloaded template
- Configure production project:
- Project name: "pro-celerbuild-example-go-prod"
- Select cluster: "pro-example-go-server-cluster(prod)"
- Click "Create Project"
- Enable deployment approval requirement
Import Project Members
- In the newly created project, find
Members
under theActions
menu and click to import project members. - Click "Import Members" to add project members.
- After importing, assign specific roles to the members:
- Set Tom as the Project Owner
- Set Jerry as the Project Master
- Set Bob as the Developer
Note:
- Development project allows direct deployment without approval
- Production project requires approval from Project Owner (Tom) or Project Master (Jerry)
- Project templates can be found in the example repository (opens in a new tab)
- Make sure to review project settings before creation
Deployment Workflows
Development Environment
Note: Development environment deployments don't require approval
Developer Role (Developer A or B)
- Create deployment application
- Execute deployment directly
- Monitor deployment status
Production Environment
1. Regular Deployment
Developer Role (Developer A or B):
- Create deployment application
- Fill in deployment details
- Submit for review
- Execute approved deployment after review
- Monitor deployment process
Project Owner/Master Role (Leader/Developer A):
- Review deployment application
- Approve/Reject with comments
- Monitor deployment status
2. Rollback Deployment
Developer Role (Developer A or B):
- Create rollback application
- Select version to rollback
- Submit for review
- Execute approved rollback after review
- Monitor rollback process
Project Owner/Master Role (Leader/Developer A):
- Review rollback application
- Approve/Reject with comments
- Monitor rollback status
Note:
- The developer who creates the deployment/rollback application is responsible for executing it after approval
- Project Owner/Master can review and approve but typically don't execute the deployment/rollback
- This workflow ensures that the developer who initiated the change is also responsible for its execution
Example Deployment Scenarios
Scenario 1: Development Branch Deployment
- Developer B (Bob) creates deployment for dev environment:
Navigate to Operations/Applications
- Select the space
go-example-space
. - Select project "pro-celerbuild-example-go-dev"
- Fill in:
- Title: "Deploy version update to Dev"
- Description: "Deploy version update to Dev.Branch: dev"
- Select dev branch (click the branch sync icon, and select the latest version)
- Click "Submit Application"
- Developer B (Bob) executes deployment:
Navigate to Operations/Tasks
- Find the deployment task
- Click "Deploy"
- Click "Start Deploy"
- Monitor deployment progress in Operation Logs
- Verify deployment:
# Check version endpoint
curl http://server:8080/version
{"version":"1.0.9"}
# Check main endpoint
curl http://server:8080/
{"message":"Hello World from CelerBuild!"}
Note:
- Replace "server" with your actual server IP address
- A response similar to
{"version":"1.0.9"}
indicates successful deployment- If you cannot access the endpoint, check:
- Server firewall settings
- Port 8080 accessibility
- Application running status
Scenario 2: Production Tag Deployment
- Developer B (Bob) creates deployment for prod environment:
Navigate to Operations/Applications
- Select project "pro-celerbuild-example-go-prod"
- Fill in:
- Title: "Deploy v1.0.5 to Production"
- Description: "Updating production version to v1.0.5"
- Submit for review
Note:
- Here we select v1.0.5 as an example
- For testing rollback operations, you can:
- First deploy v1.0.5 (refer to Rollback Operations)
- Then deploy v1.0.6
- Finally perform rollback to v1.0.5
- The deployment process remains the same regardless of which tag version you select
- Developer A (Jerry) reviews and approves:
-
- After logging in, ensure the correct space is selected.
-
- Check the notification icon for new messages. You'll see a new ticket assigned to you; click "View Details".
-
- Click "Review", select "Approved", provide feedback, and finally click "Submit Review".
- Developer B (Bob) executes deployment:
-
- After logging in, ensure the correct space is selected.
-
- Check the notifications for new messages. You'll see your ticket has been reviewed and approved; click "View Details".
-
- In the ticket details, click the "Deploy" button.
-
- Navigate to the specific task page, click "Start Deployment" to begin the deployment.
-
- Monitor the logs and server status. If any issues arise, a prompt will provide guidance.
- Verify deployment:
# Check version endpoint
curl http://server:8080/version
{"version":"1.0.5"}
# Check main endpoint
curl http://server:8080/
{"message":"Hello World from CelerBuild!"}
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
- Rollback can only be performed to previously deployed tags in the system
Tag Deployment Rollback Example
1. Initial Deployment (v1.0.5)
For detailed deployment steps, refer to the Production Tag Deployment section above.
- Developer B (Bob) creates deployment:
Navigate to Operations/Applications
- Select project "pro-celerbuild-example-go-prod"
- Fill in:
Title: "Initial Deploy v1.0.5"
Description: "Initial production deployment:
- Version: v1.0.5
- Base version for testing rollback
- All endpoints tested in development"
- Select tag "v1.0.5"
- Submit for review
- Developer A (Jerry) reviews and approves
- Developer B (Bob) executes deployment
- Verify deployment:
curl http://server:8080/version
{"version":"1.0.5"}
2. Upgrade to v1.0.6
For detailed deployment steps, refer to the Production Tag Deployment section above.
- Developer B (Bob) creates deployment:
Navigate to Operations/Applications
- Select project "pro-celerbuild-example-go-prod"
- Fill in:
- Title: "Upgrade to v1.0.6"
- Description: "Production version upgrade: From v1.0.5 To v1.0.6"
- Select tag "v1.0.6"
- Submit for review
- Developer A (Jerry) reviews and approves
- Developer B (Bob) executes deployment
- Verify upgrade:
curl http://server:8080/version
{"version":"1.0.6"}
3. Rollback to v1.0.5
- Developer B (Bob) initiates rollback:
Navigate to Operations/Applications
- Find project
- Click Actions → "Apply Rollback"
- Fill in:
- Title: "Rollback from v1.0.6 to v1.0.5"
- Description: "Rolling back production version"
- Select rollback version v1.0.5
- Submit for review
- Leader (Tom) reviews and approves:
Navigate to Operations/Applications
- Review rollback request
- Select Review Status "Approved"
- Add approval comments: "Rollback to v1.0.5 approved."
- Click "Submit Review"
Note:
- Both Project Owner (Tom) and Project Master (Jerry) have permission to review rollback requests
- In this example, we demonstrate Tom reviewing the rollback for clarity of role responsibilities
- In practice, Jerry could also review and approve this rollback request
- Developer B (Bob) executes rollback:
- Check the notifications for new messages. You'll see your ticket has been reviewed and approved; click "View Details".
- Click "Rollback"
- Click "Start Rollback"
- Monitor rollback progress
- Verify rollback:
curl http://server:8080/version
{"version":"1.0.5"}
For detailed rollback instructions, see:
Congratulations! You have successfully learned how to deploy Gin Framework using CelerBuild Pro Edition, including team-based deployment workflows, approval processes, and version management! 🎉