This repository contains a simple Flask web application containerized using Docker. It includes both:
Dockerfile(Single-stage build)Dockerfile.multistage(Multi-stage optimized build)
The project demonstrates how to containerize and deploy a Flask application using Docker best practices.
- 🐍 Backend: Flask (Python)
- 🐳 Containerization: Docker
- ⚡ Optimized Image: Multi-stage Docker build
- 🌐 Exposed Port: 5000 (Default Flask port)
.
├── app.py
├── run.py
├── requirements.txt
├── Dockerfile
├── Dockerfile.multistage
├── templates/
│ └── index.html
└── README.md
The Dockerfile builds the Flask app in a single stage.
docker build -t python-app .docker run -d -p 5000:5000 --name flask-container python-appOpen in browser:
http://localhost:5000
The Dockerfile.multistage uses multi-stage build to:
- Reduce image size
- Improve security
- Remove unnecessary build dependencies
- Follow production best practices
docker build -f Dockerfile.multistage -t flask-app-multistage .docker run -d -p 5000:5000 --name flask-container-ms flask-app-multistage- Python
- Flask
- Docker
- HTML (Jinja Templates)
Make sure Docker is installed:
docker --versionThis project demonstrates:
- How to containerize a Flask application
- Difference between single-stage and multi-stage Docker builds
- Optimizing Docker image size
- Running containers and mapping ports
- Basic deployment workflow
- Add Docker Compose
- Deploy on AWS / EC2
- Add Nginx reverse proxy
- Add CI/CD pipeline (GitHub Actions / Jenkins)
Adnan Khan CSE Student | DevOps & Cloud Enthusiast Learning Docker, AWS, Kubernetes & CI/CD 🚀