Skip to content

amitkumar0128/flask_docker_cicd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Flask App CI/CD with Docker & GitHub Actions

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.


📂 Project Structure

.
├── 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

⚙️ Tech Stack

  • Flask – Lightweight Python web framework
  • Docker – Containerizes the app
  • GitHub Actions – Automates build, test, and Docker push

🔁 CI/CD Pipeline Overview

Every push to the main branch triggers the following steps:

  1. Checkout code
  2. 📦 Install dependencies
  3. 🧪 Run unit tests
  4. 🐳 Build Docker image
  5. 🚀 Push image to Docker Hub

The pipeline is defined in .github/workflows/cicd.yml.


🧪 Running Locally

1. Clone the repo

git clone https://github.com/amitkumar0128/flask_docker_cicd.git
cd flask_docker_cicd

2. Install dependencies

pip install -r requirements.txt

3. Run the app

python app.py

App will be available at http://localhost:5000


🐳 Build & Run with Docker

Build image:

docker build -t flask-docker-ci .

Run container:

docker run -p 5000:5000 flask-docker-ci

🧪 Run Tests

python test_app.py

🐙 GitHub Actions Workflow

Update your Docker Hub credentials in GitHub:

  1. Go to your repo → SettingsSecrets and variablesActions

  2. Add these secrets:

    • DOCKER_USERNAME
    • DOCKER_PASSWORD

These will be used to authenticate and push the image to Docker Hub securely.


📦 Docker Hub Image

🐳 docker.io/akj49/flask-app


📄 License

MIT License


🙋‍♂️ Author

Amit Kumar 🔗 GitHub

About

A simple Flask app build, tested and published on Docker Hub using GitHub workflows

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages