Skip to main content

Command Palette

Search for a command to run...

🚀 CI/CD from Scratch: Flask + Jenkins + Docker

Published
•2 min read

Have you ever wondered how software updates go live without manual effort every time?
That’s where CI/CD (Continuous Integration & Continuous Delivery) comes in!

n this guide, I’ll walk you through setting up a complete CI/CD pipeline using:

  • Flask (our sample web app)

  • Jenkins (automation server)

  • Docker (container platform)

By the end, you’ll know how developers push code, and it magically gets tested, built, and deployed inside a container.

Step 1: Create a Flask App

  • Write a simple app.py Flask file.

  • Example: a “Hello World” page.

  • Test locally: python app.py

Step 2: Dockerize the App

  • Create a Dockerfile with instructions to run Flask inside a container.

  • Build image:

docker build -t flask-app .
docker run -p 5000:5000 flask-app

Now your Flask app runs inside Docker 🚀

🔹 Step 3: Set Up Jenkins

  • Install Jenkins on your system (or in a Docker container).

  • Access it via http://localhost:8080

  • Install required plugins:

  • Git

  • Docker Pipeline

  • Pipeline

Step 4: Connect GitHub + Jenkins

  • Push your Flask code to GitHub.

  • In Jenkins, create a Pipeline job.

  • Link your GitHub repo (via webhooks or polling).

Step 5: Write a Jenkinsfile

Inside your project, add a Jenkinsfile:

pipeline {
    agent any

    stages {
        stage('Clone Code') {
            steps {
                git 'https://github.com/your-repo/flask-app.git'
            }
        }

        stage('Build Docker Image') {
            steps {
                sh 'docker build -t flask-app .'
            }
        }

        stage('Run Container') {
            steps {
                sh 'docker run -d -p 5000:5000 flask-app'
            }
        }
    }
}

This tells Jenkins exactly what to do after every code push.

🔹 Step 6: Run the Pipeline

  • Push changes to GitHub.

  • Jenkins automatically:

  1. Pulls your code

  2. Builds a Docker image

  3. Runs it in a container

💡 That’s CI/CD in action — no manual builds, no manual deploys!

🎯 Final Thoughts

We just created a basic CI/CD pipeline for a Flask app using Jenkins + Docker.

  • Developers push code → Jenkins builds & deploys automatically.

  • No downtime, no delays, smooth automation.

This is the foundation of DevOps pipelines used in real companies.
Next steps? Add testing, staging environments, and maybe Kubernetes 🚀

More from this blog

Amazon S3 Storage Classes

43 posts