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

2. Initial Setup Process (by Tom)

2.1 Create Users

  1. Navigate to Base/Users
  2. 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

Create Users

2.2 Create and Configure Space

  1. Navigate to Spaces/Spaces
  2. Create new space:
    • Name: go-example-space
  3. Set space ownership:
    • Set self (Tom) as Space Owner

Create Space

3. Create Server Infrastructure

3.1 Create Server Clusters

  1. Navigate to Base/Server Clusters
  2. Create development cluster:
    • Click "New"
    • Fill in cluster details:
      • Name: pro-example-go-server-cluster(dev)
    • Click "Submit"

image

  1. Create production cluster:
    • Click "New"
    • Fill in cluster details:
      • Name: pro-example-go-server-cluster(prod)
    • Click "Submit"

image

3.2 Add Servers

  1. Navigate to Base/Servers
  2. 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"

image

  1. 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"

image

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 Dev Template

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

  1. Navigate to Projects/Projects
  2. Click "Import YAML"
  3. Upload the downloaded template
  4. Configure development project:
    • Project name: "pro-celerbuild-example-go-dev"
    • Disable deployment approval requirement (It is off by default)
  5. Click "Create"

image image

Add team members:

  • Jerry (Project Master)
  • Bob (Developer)

image image image

4.2 Production Project

Download Template

Download Prod Template

Import Template
  1. Navigate to Projects/Projects
  2. Click "Import YAML"
  3. Upload the downloaded template
  4. Configure production project:
    • Project name: "pro-celerbuild-example-go-prod"
  5. Click "Create"

Import Prod Project image

Enable deployment approval requirement

image

Add team members:

  • Jerry (Project Master)
  • Bob (Developer)

Set Jerry as Project Master

image image image

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)

  1. Create deployment application
  2. Execute deployment directly
  3. 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

  1. 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"

Create Dev Deployment image

  1. Developer B (Bob) executes deployment:
Navigate to `Operations/Tasks`
- Find the deployment task
- Click "Deploy"
- Click "Start Deploy"
- Monitor deployment progress in Operation Logs

Execute Dev Deployment image

  1. 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

  1. 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:
    1. First deploy v1.0.5 (refer to Rollback Operations)
    2. Then deploy v1.0.6
    3. Finally perform rollback to v1.0.5
  • The deployment process remains the same regardless of which tag version you select

image image

  1. 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"

image image

  1. Developer B (Bob) executes deployment:
Navigate to `Operations/Tasks`
- Find approved deployment
- Click "Deploy"
- Click "Start Deploy"
- Monitor deployment progress

image

image

image

  1. 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.

  1. 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
  1. Developer A (Jerry) reviews and approves
  2. Developer B (Bob) executes deployment
  3. 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.

  1. 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
  1. Developer A (Jerry) reviews and approves
  2. Developer B (Bob) executes deployment
  3. Verify upgrade:
curl http://server:8080/version
{"version":"1.0.6"}

3. Rollback to v1.0.5

  1. 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

image image

  1. 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"

image image

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
  1. Developer B (Bob) executes rollback:
Navigate to `Operations/Tasks`
- Find rollback task
- Click "Rollback"
- Click "Start Rollback"
- Monitor rollback progress

image image image

  1. Verify rollback:
curl http://server:8080/version
{"version":"1.0.5"}

For detailed rollback instructions, see: