Advertisement Space - Google AdSense
Key Features
🚀 ECS Fargate - serverless container orchestration
📈 Auto-scaling based on CPU/memory metrics
🔒 Private container registry with ECR
⚖️ Application Load Balancer for traffic distribution
💰 Cost: ~$15-30/month for 1 task (256 CPU, 512 MB)
📊 CloudWatch Logs for centralized logging
📋 Configuration Files
Copy these files into your project:
.github/workflows/deploy.yml
# .github/workflows/deploy.yml
name: Deploy Docker to AWS ECS Fargate
on:
push:
branches:
- main
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: my-app
ECS_SERVICE: my-app-service
ECS_CLUSTER: my-app-cluster
ECS_TASK_DEFINITION: my-app-task
CONTAINER_NAME: my-app-container
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
# Dockerfile
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
RUN npm run build
FROM node:20-alpine
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
COPY package*.json ./
EXPOSE 3000
CMD ["node", "dist/index.js"]
# task-definition.json
{
"family": "my-app-task",
"networkMode": "awsvpc",
"requiresCompatibilities": ["FARGATE"],
"cpu": "256",
"memory": "512",
"executionRoleArn": "arn:aws:iam::YOUR_ACCOUNT_ID:role/ecsTaskExecutionRole",
"taskRoleArn": "arn:aws:iam::YOUR_ACCOUNT_ID:role/ecsTaskRole",
"containerDefinitions": [
{
"name": "my-app-container",
"image": "YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/my-app:latest",
"portMappings": [
{
"containerPort": 3000,
"protocol": "tcp"
}
],
"essential": true,
"environment": [
{
"name": "NODE_ENV",
"value": "production"
}
],
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/my-app",
"awslogs-region": "us-east-1",
"awslogs-stream-prefix": "ecs"
}
}
}
]
} 📦 Need all the files?
Download the complete blueprint with README, package.json, and all configuration files.
📥 Browse All FilesConfiguration Summary
🚀
Framework
Docker
☁️
Cloud Provider
Amazon Web Services
⚙️
Deployment Tool
GitHub Actions
💰
Pricing
Pay-as-you-go with free tier available
☁️ About Amazon Web Services
Leading cloud platform with comprehensive services
✓ Best For
Enterprise applications, scalable infrastructure, comprehensive service ecosystem
💰 Pricing
Pay-as-you-go with free tier available
Available Services:
✓ S3 - Object Storage
✓ CloudFront - CDN
✓ EC2 - Virtual Machines
✓ Lambda - Serverless Functions
✓ ECS/EKS - Container Orchestration
✓ Route 53 - DNS Management
✓ CloudFormation - Infrastructure as Code
✓ Amplify - Frontend Hosting
✓ RDS - Managed Databases
✓ DynamoDB - NoSQL Database
✅ Prerequisites
Make sure you have these ready before starting:
✓ AWS account with billing enabled
✓ AWS CLI installed and configured
✓ Docker installed locally for testing
✓ GitHub repository with admin access
✓ Basic knowledge of Docker and AWS ECS
✓ VPC with public subnets configured
🚀 Step-by-Step Implementation
Follow these steps to deploy your Docker application:
- 1Install AWS CLI: https://aws.amazon.com/cli/
- 2Create ECR repository: aws ecr create-repository --repository-name my-app
- 3Create ECS cluster: aws ecs create-cluster --cluster-name my-app-cluster
- 4Create CloudWatch log group: aws logs create-log-group --log-group-name /ecs/my-app
- 5Create IAM execution role with AmazonECSTaskExecutionRolePolicy
- 6Create IAM task role with necessary permissions
- 7Update task-definition.json with your AWS account ID and ARNs
- 8Register task definition: aws ecs register-task-definition --cli-input-json file://task-definition.json
- 9Create Application Load Balancer (ALB) in AWS Console
- 10Create target group for port 3000
- 11Create ECS service with ALB: aws ecs create-service --cluster my-app-cluster --service-name my-app-service --task-definition my-app-task --desired-count 1 --launch-type FARGATE --network-configuration "awsvpcConfiguration={subnets=[subnet-xxx],securityGroups=[sg-xxx],assignPublicIp=ENABLED}" --load-balancers "targetGroupArn=arn:aws:elasticloadbalancing:...,containerName=my-app-container,containerPort=3000"
- 12Create IAM user for GitHub Actions with ECR and ECS permissions
- 13Add AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to GitHub Secrets
- 14Create .github/workflows/deploy.yml
- 15Commit and push to main branch
- 16Monitor deployment in GitHub Actions and ECS Console
💡 Additional Notes & Tips
- 🎯 Blue/green deployments supported
- ⚠️ Requires VPC, subnets, and security groups setup
- 💡 Consider AWS Copilot CLI for easier management
- 🔧 Use Fargate Spot for 70% cost savings (non-critical workloads)
📚 About This Stack
🐳 Docker
Containerization platform for consistent deployments
☁️ AWS
Leading cloud platform with comprehensive services
⚙️ GitHub Actions
CI/CD automation directly in GitHub
🏷️ Tags & Keywords
Docker AWS Amazon Web Services GitHub Actions CI/CD DevOps Infrastructure as Code Docker Deployment AWS Hosting Production Ready 2026Advertisement Space - Google AdSense