🚀 Project 21 — Dockerizing a Python App with CI/CD (Flask + GitHub Actions + Docker Hub)

🚀 Project 21 — Dockerizing a Python App with CI/CD (Flask + GitHub Actions + Docker Hub)

In Project 21, we built a small Python Flask application, containerized it with a multi-stage Dockerfile, and automated the build + push pipeline using GitHub Actions.

This project demonstrates how to go from a simple app to a production-ready Docker image, with CI/CD integration to Docker Hub. Here’s the journey 👇

🔹 What we built

  • A simple Flask API that returns a JSON response.
  • A Dockerfile following best practices: Multi-stage build (smaller images). | Runs with gunicorn instead of Flask dev server. | Non-root user for security.
  • A .dockerignore to keep the image clean.
  • A GitHub Actions workflow that: Builds the image on every push to main. | Pushes to Docker Hub automatically.

Why this matters

  • Portable: app runs the same everywhere.
  • Automated: no manual Docker builds.
  • Secure: uses a slim base image + non-root user.
  • CI/CD Ready: push code → get fresh Docker image in Docker Hub.

🔹 How to run locally

docker build -t dockerfile-python:local .
docker run --rm -p 5000:5000 dockerfile-python:local        

Open 👉 http://localhost:5000

🔹 Next steps

  • Add a test stage (pytest) before building images.
  • Extend CI/CD to auto-deploy on EC2.
  • Enable multi-arch builds (amd64 + arm64).

👉 This project shows how Docker + GitHub Actions work hand-in-hand to ship apps faster.



To view or add a comment, sign in

More articles by Raghavender Chari

Explore content categories