A simple Flask application that is automatically built, tested, and pushed to Docker Hub using GitHub Actions. This project demonstrates a lightweight CI/CD pipeline for containerized apps.
.
├── app.py # Main Flask application
├── test_app.py # Unit tests for the app
├── Dockerfile # Docker image build instructions
├── requirements.txt # Python dependencies
├── .gitignore
├── README.md
└── .github/
└── workflows/
└── cicd.yml # GitHub Actions workflow
- Flask – Lightweight Python web framework
- Docker – Containerizes the app
- GitHub Actions – Automates build, test, and Docker push
Every push to the main
branch triggers the following steps:
- ✅ Checkout code
- 📦 Install dependencies
- 🧪 Run unit tests
- 🐳 Build Docker image
- 🚀 Push image to Docker Hub
The pipeline is defined in
.github/workflows/cicd.yml
.
git clone https://github.com/amitkumar0128/flask_docker_cicd.git
cd flask_docker_cicd
pip install -r requirements.txt
python app.py
App will be available at
http://localhost:5000
docker build -t flask-docker-ci .
docker run -p 5000:5000 flask-docker-ci
python test_app.py
Update your Docker Hub credentials in GitHub:
-
Go to your repo → Settings → Secrets and variables → Actions
-
Add these secrets:
DOCKER_USERNAME
DOCKER_PASSWORD
These will be used to authenticate and push the image to Docker Hub securely.
MIT License
Amit Kumar 🔗 GitHub