Architecture Overview
Our stack: Django + Gunicorn behind Nginx, PostgreSQL on RDS, static/media files on S3 + CloudFront, secrets in AWS Secrets Manager, and the whole thing orchestrated by ECS Fargate.
Dockerfile
Use a multi-stage build: a builder stage installs Python dependencies, and a slim final stage copies only what's needed. This cuts image size by ~60%.
ECS Task Definition
Define your container, CPU/memory limits, environment variables pulled from Secrets Manager, and a health check endpoint. Use Fargate to avoid managing EC2 instances.
GitHub Actions Pipeline
On every push to main: run pytest, build the Docker image, push to ECR, update the ECS service. Zero-downtime rolling deploys are handled by ECS automatically.
Cost Optimisation
Use Fargate Spot for non-critical workloads (70% cheaper), RDS t3.micro for small apps, and CloudFront to cache static assets at the edge.
Comments (0)
No comments yet
Be the first to share your thoughts!