Skip to content

Latest commit

Β 

History

History
133 lines (87 loc) Β· 2.2 KB

File metadata and controls

133 lines (87 loc) Β· 2.2 KB

πŸš€ Flask App Deployment with Docker

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.


πŸ“Œ Project Overview

  • 🐍 Backend: Flask (Python)
  • 🐳 Containerization: Docker
  • ⚑ Optimized Image: Multi-stage Docker build
  • 🌐 Exposed Port: 5000 (Default Flask port)

πŸ“‚ Project Structure

.
β”œβ”€β”€ app.py
β”œβ”€β”€ run.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ Dockerfile.multistage
β”œβ”€β”€ templates/
β”‚   └── index.html
└── README.md

🐳 Dockerfile (Single Stage)

The Dockerfile builds the Flask app in a single stage.

πŸ”Ή Build Image

docker build -t python-app .

πŸ”Ή Run Container

docker run -d -p 5000:5000 --name flask-container python-app

Open in browser:

http://localhost:5000

🐳 Dockerfile.multistage (Multi-Stage Build)

The Dockerfile.multistage uses multi-stage build to:

  • Reduce image size
  • Improve security
  • Remove unnecessary build dependencies
  • Follow production best practices

πŸ”Ή Build Multi-stage Image

docker build -f Dockerfile.multistage -t flask-app-multistage .

πŸ”Ή Run Container

docker run -d -p 5000:5000 --name flask-container-ms flask-app-multistage

πŸ›  Technologies Used

  • Python
  • Flask
  • Docker
  • HTML (Jinja Templates)

πŸ“¦ Requirements

Make sure Docker is installed:

docker --version

🎯 Key Learning Objectives

This 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

πŸš€ Future Improvements

  • Add Docker Compose
  • Deploy on AWS / EC2
  • Add Nginx reverse proxy
  • Add CI/CD pipeline (GitHub Actions / Jenkins)

πŸ‘¨β€πŸ’» Author

Adnan Khan CSE Student | DevOps & Cloud Enthusiast Learning Docker, AWS, Kubernetes & CI/CD πŸš€