Deploying Go Projects with Gin Framework (Pro Version)
This guide demonstrates how to deploy a Go project using CelerBuild Pro Version, covering both branch and tag deployments 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
2.2 Create and Configure Space
- Navigate to
Spaces/Spaces
- Create new space:
- Name: go-example-space
- Set space ownership:
- Set self (Tom) as Space Owner
3. Create Server Infrastructure
3.1 Create Server Clusters
- Navigate to
Base/Server Clusters
- Create development cluster:
- Click "New"
- Fill in cluster details:
- Name: pro-example-go-server-cluster(dev)
- Click "Submit"
- Create production cluster:
- Click "New"
- Fill in cluster details:
- Name: pro-example-go-server-cluster(prod)
- Click "Submit"
3.2 Add Servers
- Navigate to
Base/Servers
- Add development server:
-
Click "New"
-
Fill in server details:
- Server Name: pro-go-dev-server-1
- Server IP: Your server IP
- SSH Port: Your SSH port (default: 22)
-
Select cluster: pro-example-go-server-cluster(dev)
-
Click "Submit"
-
- Add production server:
- Click "New"
- Fill in server details:
- Server Name: pro-go-prod-server-1
- Server IP: Your server IP
- SSH Port: Your SSH port (default: 22)
- Select cluster: pro-example-go-server-cluster(prod)
- Click "Submit"
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
4. Create Projects
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"
- Disable deployment approval requirement (It is off by default)
- Click "Create"
Add team members:
- Jerry (Project Master)
- Bob (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
- Navigate to
Projects/Projects
- Click "Import YAML"
- Upload the downloaded template
- Configure production project:
- Project name: "pro-celerbuild-example-go-prod"
- Click "Create"
Enable deployment approval requirement
Add team members:
- Jerry (Project Master)
- Bob (Developer)
Set Jerry as Project Master
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 project "pro-celerbuild-example-go-dev"
- Fill in:
Title: "Deploy version update to Dev"
Description: "Updating version constant in routes.go:
- Changed Version constant from 1.0.5 to 1.0.6
- Testing version endpoint update
Branch: dev"
- Select dev branch
- 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.6"}
# Check main endpoint
curl http://server:8080/
{"message":"Hello World from CelerBuild!"}
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.6 to Production"
Description: "Updating production version to 1.0.6:
- Version constant updated in routes.go
- All endpoints tested in development
- No breaking changes"
- Select tag "v1.0.6"
- Submit for review
Note:
- Here we select v1.0.6 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:
Navigate to `Operations/Applications`
- Find pending deployment
- Review deployment details
- Add approval comments:
"Version update verified in development environment.
Basic endpoints tested successfully.
Approved for production deployment."
- Click "Approve"
- Developer B (Bob) executes deployment:
Navigate to `Operations/Tasks`
- Find approved deployment
- Click "Deploy"
- Click "Start Deploy"
- Monitor deployment progress
- Verify deployment:
# Check version endpoint
curl http://server:8080/version
{"version":"1.0.6"}
# 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
- All endpoints verified in development"
- 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:
- Current version: v1.0.6
- Target version: v1.0.5
- Reason: Version compatibility issues
- Impact: Minor API inconsistencies
- Urgency: High"
- Select rollback version v1.0.5
- Submit for review
- Leader (Tom) reviews and approves:
Navigate to `Operations/Applications`
- Review rollback request
- Add approval comments:
"Reviewed version compatibility issues.
Confirmed API inconsistencies in v1.0.6.
Rollback to v1.0.5 approved."
- Click "Approve"
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:
Navigate to `Operations/Tasks`
- Find rollback task
- Click "Rollback"
- Click "Start Rollback"
- Monitor rollback progress
- Verify rollback:
curl http://server:8080/version
{"version":"1.0.5"}
For detailed rollback instructions, see: