This document outlines the deployment flows for both staging and production environments.
graph TD
A[Push to Main Branch] --> B[Build Application]
B --> C[Run Tests]
C --> D{Tests Pass?}
D -->|Yes| E[Configure AWS Credentials]
D -->|No| F[Pipeline Fails]
E --> G[Build Docker Image]
G --> H[Push to AWS ECR]
H --> I[Create New Task Definition]
I --> J[Update ECS Service]
J --> K[Start Rolling Update]
K --> L[Load Balancer Health Check]
L --> M{Health Check Pass?}
M -->|Yes| N[Replace Old Tasks]
M -->|No| O[Rollback to Previous Version]
N --> P[Application Live on Staging]
graph TD
A[Release Published] --> B[Build Application]
B --> C[Run Tests]
C --> D{Tests Pass?}
D -->|Yes| E[Push to AWS ECR]
D -->|No| F[Pipeline Fails]
E --> G[Configure AWS Production Credentials]
G --> H[Create New Task Definition]
H --> I[Update ECS Service]
I --> J[Start Rolling Update]
J --> K[Load Balancer Health Check]
K --> L{Health Check Pass?}
L -->|Yes| M[Replace Old Tasks]
L -->|No| N[Rollback to Previous Version]
M --> O[Application Live on Production]
- Developer pushes code to the
main
branch - GitHub Actions triggers the staging pipeline
- Application is built using .NET 8.0
- All tests are executed
- On successful tests:
- AWS staging credentials are configured
- Docker image is built
- Image is pushed to AWS ECR staging registry
- Post-ECR Deployment Process:
- New task definition is created in ECS with the latest image
- ECS service is updated with the new task definition
- Rolling update process begins:
- New tasks are started with the new task definition
- Application Load Balancer starts health checks on new tasks
- Health check endpoint is monitored for successful responses
- If health checks pass, old tasks are gradually terminated
- If health checks fail, automatic rollback to previous version
- Load Balancer continues routing traffic to healthy tasks
- Deployment is considered complete when all tasks are replaced
- A new release is published
- GitHub Actions triggers the production pipeline
- Application is built using .NET 8.0
- All tests are executed
- On successful tests:
- AWS production credentials are configured
- Docker image is built
- Image is pushed to AWS ECR production registry
- Post-ECR Deployment Process:
- New task definition is created in ECS with the latest image
- ECS service is updated with the new task definition
- Rolling update process begins:
- New tasks are started with the new task definition
- Application Load Balancer starts health checks on new tasks
- Health check endpoint is monitored for successful responses
- If health checks pass, old tasks are gradually terminated
- If health checks fail, automatic rollback to previous version
- Load Balancer continues routing traffic to healthy tasks
- Deployment is considered complete when all tasks are replaced
- AWS ECR (Elastic Container Registry) - For storing Docker images
- AWS ECS (Elastic Container Service) - For running containerized applications
- GitHub Actions - CI/CD pipeline orchestration
- Application Load Balancer (ALB):
- Performs health checks on container instances
- Routes traffic to healthy tasks
- Supports rolling updates with zero downtime
- ECS Task Definition:
- Defines container specifications
- Configures health check parameters
- Specifies resource requirements
- ECS Service:
- Manages task lifecycle
- Handles rolling updates
- Maintains desired task count
- Integrates with Load Balancer
- Path:
/health
- Protocol: HTTPS
- Healthy threshold: 3 consecutive successes
- Unhealthy threshold: 2 consecutive failures
- Timeout: 5 seconds
- Interval: 30 seconds
- Success codes: 200-299