Staging Deployment & CI/CD Pipeline Documentation

Staging Deployment & CI/CD Pipeline Documentation

1. Overview

This document provides a clear, end-to-end description of the staging deployment setup and the unified CI/CD pipeline implemented for the HeliumAI platform. A single pipeline is used to manage deployments for both staging and production, with strict controls enforced through branch-based execution.

The staging environment is currently deployed and validated in the ap-south-1 (Mumbai) region.


2. Architecture Summary

  • ๐ŸŒ Frontend Domain: https://www.heliumai.space

  • ๐Ÿ”Œ Backend API Domain: https://api.heliumai.space

  • ๐Ÿงฎ Compute Platform: AWS ECS (Fargate)

  • ๐Ÿ“ฆ Container Registry: Amazon ECR

  • ⚖️ Load Balancer: Application Load Balancer (ALB)

  • ๐Ÿš€ Traffic Acceleration: AWS Global Accelerator

  • ๐Ÿ” CI/CD Platform: GitHub Actions


3. Environments & Branch Mapping

Environment Git BranchDeployment Scope
Staging   kartik-stg         Mumbai (ap-south-1)
Production migrated-demo2      Mumbai, Singapore, Virginia

Branch-based mapping ensures strong isolation between environments and prevents accidental cross-environment deployments.


4. CI/CD Pipeline Overview

A single GitHub Actions pipeline is responsible for:

  • ๐Ÿ—️ Building Docker images

  • ๐Ÿ“ค Pushing images to Amazon ECR

  • ๐Ÿšข Deploying services to Amazon ECS

Pipeline execution is strictly gated by Git branch, enabling controlled promotion from staging to production without maintaining multiple workflows.


5. Pipeline Trigger Strategy

Trigger Conditions

  • ๐Ÿ”” Automatic trigger on git push to environment-specific branches

This approach keeps the pipeline simple while ensuring deployments only occur from explicitly approved branches.


6. Global Pipeline Configuration

Image Tagging Strategy

  • ๐Ÿท️ Docker images are tagged using: v${github.run_number}

  • ๐Ÿ” Guarantees unique, incremental, and traceable image versions

Image Repository Strategy

  • ๐Ÿ“ฆ Single Amazon ECR repository: helium-backend

  • ♻️ The same image artifact is reused across environments, eliminating unnecessary rebuilds


7. Build Stage – Docker Image Creation

Purpose

  • ๐Ÿงฑ Build ARM64-compatible Docker images

  • ๐Ÿ“ค Push images to Amazon ECR

Build Flow

  1. ๐Ÿ“ฅ Checkout application source code

  2. ๐Ÿ› ️ Initialize Docker Buildx

  3. ๐Ÿ” Authenticate with AWS

  4. ๐Ÿ—️ Build ARM64 Docker image

  5. ๐Ÿท️ Tag image with pipeline run number

  6. ๐Ÿ“ฆ Push image to ECR

  7. ๐Ÿ“ค Export image URI for downstream deployment stages


8. Staging Deployment – End-to-End Flow (Mumbai)

This section documents the complete staging deployment lifecycle, from infrastructure readiness to application validation.

8.1 Preconditions

  • ๐ŸŒฟ Git branch: kartik-stg

  • ๐Ÿงฉ ECS cluster: helium-mumbai-staging-cluster

  • ๐Ÿ“ฆ ECR repository available in ap-south-1

  • ⚖️ ALB and target groups configured for staging services


8.2 Deployment Trigger

  • ๐Ÿš€ Deployment is automatically initiated on:

    • git push to the kartik-stg branch


8.3 Staging Networking & Access Setup (Pre-Deployment)

  1. ๐ŸŒ AWS Global Accelerator configured for staging traffic

  2. ๐ŸŽฏ Accelerator endpoint attached to the staging ALB in ap-south-1

  3. ๐ŸŒ Separate staging domain configured: heliumai.space

  4. ๐Ÿ”’ New ACM certificate created for heliumai.space

  5. ✅ Certificate validated using DNS validation

  6. ๐Ÿงญ CNAME record added in Route 53 pointing the domain to the Global Accelerator DNS name


8.4 Build Phase (CI)

  1. ๐Ÿ” GitHub Actions workflow is triggered

  2. ๐Ÿ“ฅ Source code is checked out

  3. ๐Ÿ› ️ Docker Buildx is initialized

  4. ๐Ÿ—️ ARM64 Docker image is built

  5. ๐Ÿท️ Image is tagged using v${github.run_number}

  6. ๐Ÿ“ฆ Image is pushed to Amazon ECR (Mumbai)

  7. ๐Ÿ“ค Image URI is exported for deployment


8.5 Deploy Phase (CD)

Execution Condition:

  • ๐Ÿšจ Runs only when the active branch is kartik-stg

Services Deployed:

  • ๐Ÿ”ต Backend service

  • ⚙️ Worker service

Deployment Steps:

  1. ๐Ÿ” Configure AWS credentials for ap-south-1

  2. ๐Ÿ“ฅ Download the current ECS task definition

  3. ๐Ÿงน Remove AWS-managed metadata fields

  4. ๐Ÿ–ผ️ Inject the newly built Docker image

  5. ๐Ÿงพ Register a new task definition revision

  6. ๐Ÿ”„ Update the ECS service to use the new revision

  7. ⏳ Wait for ECS service stability


8.6 Post-Deployment Validation

  • ✅ Confirm ECS services are stable

  • ๐Ÿ“‹ Verify new task definition revisions are running

  • ๐ŸŒ Validate application access via the staging domain


9. Production Deployment Flow (Multi-Region)

Execution Condition

  • ๐Ÿšจ Triggered only when code is pushed to the migrated-demo2 branch

Safety Controls

  • ๐Ÿ” Strict branch-based gating

  • ๐Ÿ›‘ Prevents unintended production deployments

Target Regions & Clusters

RegionECS Cluster
Mumbai    helium-mumbai-cluster
Singapore    helium-singapore-cluster
Virginia    helium-virginia-cluster

Deployment Steps (Per Region)

  1. ๐Ÿ” Configure AWS credentials for the target region

  2. ๐Ÿ“ฅ Retrieve existing ECS task definition

  3. ๐Ÿงน Remove AWS-managed fields

  4. ๐Ÿ–ผ️ Inject region-specific Docker image

  5. ๐Ÿงพ Register a new task definition revision

  6. ๐Ÿš€ Deploy the updated task definition to ECS

  7. ⏳ Wait for service stability confirmation


10. Security & Secrets Management

  • ๐Ÿ”’ AWS credentials are securely stored in GitHub Secrets

  • ๐Ÿšซ No credentials or sensitive values are hardcoded


11. Benefits of the Current Setup

  • ✅ Single CI/CD pipeline for all environments

  • ๐Ÿ” Strong deployment safety through branch isolation

  • ♻️ Reusable Docker artifacts across environments

  • ๐ŸŒ Multi-region production readiness

  • ๐Ÿงผ Clean, scalable, and maintainable architecture


12. Final Summary

This document captures a well-structured, production-ready CI/CD and staging deployment architecture for HeliumAI. The approach ensures safe staging validation, seamless promotion to production, and consistent deployments using a single, controlled pipeline.

Comments

Popular posts from this blog

AWS Global Accelerator (GA) & Route 53 Integration Documentation

End-To-End-Documentation