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
- Python 3.12
- Flask 3.x
- Docker
- AWS CodePipeline
- AWS CodeBuild
- AWS CodeDeploy
- Amazon EC2 (Amazon Linux 2 / Ubuntu)
-
Source
Code is pushed to the GitHub repository (main
branch). -
Build (CodeBuild)
- Installs dependencies using
requirements.txt
- Builds a Docker image using the
Dockerfile
- Pushes the image to Docker Hub (or any registry)
- Installs dependencies using
-
Deploy (CodeDeploy)
- Pulls the image from Docker Hub on the EC2 instance
- Uses
appspec.yml
to runscripts/stop-container.sh
andscripts/start-container.sh
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
- Fork or clone this repo
- 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!
- 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
When deployed, open your EC2 public IP on port 5000
:
This project is open-source and free to use for learning and experimentation.