A minimal Flask web application built for learning containerization and deployment to AWS ECS (Elastic Container Service).
Part of the TrainWithShubham — DevOps Zero To Hero course.
- Responsive landing page with modern glassmorphism UI
/healthendpoint for ECS load balancer health checks- Two Dockerfiles — simple and multistage (distroless)
| Component | Technology |
|---|---|
| Framework | Flask 3.1.1 |
| Runtime | Python 3.14 |
| Container | Docker (python-slim / distroless) |
| Deploy | AWS ECS |
flask-app-ecs/
├── app.py # Flask app with routes
├── run.py # Entry point (host 0.0.0.0, port 80)
├── requirements.txt # Python dependencies
├── templates/
│ └── index.html # Landing page
├── Dockerfile # Simple single-stage build
└── Dockerfile-multi # Multistage build with distroless
pip install -r requirements.txt
python run.pyApp runs at http://localhost:80.
Simple build:
docker build -t flask-app .
docker run -p 80:80 flask-appMultistage build (smaller, production-grade):
docker build -f Dockerfile-multi -t flask-app .
docker run -p 80:80 flask-appSingle-stage build using python:3.14-slim. Straightforward — copies everything, installs dependencies, runs the app. Good for development and learning.
Two-stage build:
- Builder stage — installs dependencies into a separate directory using
python:3.14-slim - Final stage — copies only the app and deps into a
distrolessimage
Benefits:
- Smaller final image (no pip, no shell, no OS utilities)
- Reduced attack surface — distroless images contain only the app and its runtime
- Better layer caching — dependencies are copied before source code
| Route | Method | Description |
|---|---|---|
/ |
GET | Landing page |
/health |
GET | Health check (returns Server is up and running) |
High-level steps to deploy this app on ECS:
-
Push image to ECR
aws ecr get-login-password --region <region> | docker login --username AWS --password-stdin <account-id>.dkr.ecr.<region>.amazonaws.com docker tag flask-app:latest <account-id>.dkr.ecr.<region>.amazonaws.com/flask-app:latest docker push <account-id>.dkr.ecr.<region>.amazonaws.com/flask-app:latest
-
Create ECS Task Definition — specify the ECR image, port 80, memory/CPU limits
-
Create ECS Service — attach to a cluster, configure desired count, link to a load balancer
-
Configure ALB — target group pointing to port 80, use
/healthas the health check path