Skip to content

πŸš€ A simple Python Flask app containerized with Docker and deployed using AWS CodePipeline and CodeDeploy on EC2.

License

Notifications You must be signed in to change notification settings

RoshanKumar770/simple-python-flask-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Simple Flask Docker App with CI/CD on AWS

This repository contains a basic Python Flask web application that is:

βœ… Containerized using Docker
βœ… Built and pushed via AWS CodeBuild
βœ… Deployed to EC2 using AWS CodeDeploy
βœ… Fully automated with AWS CodePipeline


πŸ› οΈ Tech Stack

  • Python 3.12
  • Flask 3.x
  • Docker
  • AWS CodePipeline
  • AWS CodeBuild
  • AWS CodeDeploy
  • Amazon EC2 (Amazon Linux 2 / Ubuntu)

πŸ” CI/CD Workflow

  1. Source
    Code is pushed to the GitHub repository (main branch).

  2. Build (CodeBuild)

    • Installs dependencies using requirements.txt
    • Builds a Docker image using the Dockerfile
    • Pushes the image to Docker Hub (or any registry)
  3. Deploy (CodeDeploy)

    • Pulls the image from Docker Hub on the EC2 instance
    • Uses appspec.yml to run scripts/stop-container.sh and scripts/start-container.sh

πŸ“ Project Structure

simple-python-flask-app/ β”œβ”€β”€ app.py # Flask application β”œβ”€β”€ requirements.txt # Python dependencies β”œβ”€β”€ Dockerfile # Docker image instructions β”œβ”€β”€ buildspec.yml # CodeBuild build instructions β”œβ”€β”€ appspec.yml # CodeDeploy deployment instructions β”œβ”€β”€ scripts/ β”‚ β”œβ”€β”€ start-container.sh # Starts the Docker container β”‚ └── stop-container.sh # Stops the Docker container └── README.md # Project documentation


πŸš€ How to Deploy

  1. Fork or clone this repo
  2. Set up AWS resources: EC2 instance, CodeDeploy App## πŸ“„ License

This project is open-source and free to use for learning and experimentation.& Deployment Group 3. Connect GitHub repo to AWS CodePipeline 4. Provide DockerHub credentials via Parameter Store (for buildspec) 5. Push changes to main branch β†’ CI/CD kicks in!


πŸ“Œ Notes

  • Make sure your EC2 instance has Docker installed and IAM permissions for CodeDeploy.
  • Your EC2 security group must allow inbound on port 5000 (Flask default).
  • Scripts must have execution permission: chmod +x scripts/*.sh

πŸ“· Sample Output

When deployed, open your EC2 public IP on port 5000:


πŸ“„ License

This project is open-source and free to use for learning and experimentation.

About

πŸš€ A simple Python Flask app containerized with Docker and deployed using AWS CodePipeline and CodeDeploy on EC2.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published