GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - k5sha/jenkins-python-api: Lightweight Python FastAPI microservice with automated pytest testing, Docker containerization, and a fully automated Jenkins CI/CD deployment pipeline.

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
dev
dev
 
 
jenkins
jenkins
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
README.md
README.md
 
 
main.py
main.py
 
 
requirements.txt
requirements.txt
 
 
test_main.py
test_main.py
 
 

Repository files navigation

šŸš€ Python FastAPI CI/CD Pipeline with Jenkins & Docker

A lightweight, production-ready Python FastAPI microservice featuring automated testing with pytest, containerization, robust health checking, and a fully automated CI/CD deployment pipeline powered by Jenkins and Docker.

Screenshot 2026-07-21 at 19 56 39

šŸ› ļø Tech Stack & Tools

  • Backend: Python 3.11, FastAPI, Uvicorn
  • Testing: Pytest, HTTPX (TestClient)
  • Containerization: Docker, Docker Compose
  • CI/CD Automation: Jenkins (Declarative Pipeline)
  • Version Control: Git & GitHub

šŸ“‚ Project Structure

ā”œā”€ā”€ main.py              # FastAPI application entry point
ā”œā”€ā”€ test_main.py         # Automated API tests using pytest
ā”œā”€ā”€ requirements.txt     # Python project dependencies
ā”œā”€ā”€ Dockerfile           # Docker image configuration for the API
└── jenkins/
    └── Jenkinsfile      # CI/CD pipeline definition

šŸ“‹ Prerequisites & Required Plugins

To run and deploy this project locally using Jenkins and Docker, ensure you have the following installed and configured:

1. System Requirements

  • Docker & Docker Compose installed on your host machine.
  • Linux/Debian-based environment (recommended for Docker socket mapping).

2. Jenkins Setup & Plugins

Your Jenkins container must have access to the host's Docker daemon to build and deploy containers from the pipeline.

  • Docker-in-Docker / Docker-outside-of-Docker (DooD): Configured via volume mounting (/var/run/docker.sock).
  • Jenkins Plugins:
  • Git Plugin (for repository checkout)
  • Pipeline Plugin (for declarative pipeline support)
  • Docker Pipeline Plugin (optional, if using agent-level docker blocks)

šŸš€ Getting Started Locally

1. Clone the Repository

git clone https://github.com/your-username/your-repo-name.git
cd your-repo-name

2. Run Jenkins via Docker Compose

Start your local Jenkins server with Docker socket access enabled:

docker compose up --build -d

Access Jenkins at http://localhost:8080.

3. Run the FastAPI App Locally (Optional)

If you want to run the application manually without Jenkins:

# Install dependencies
pip install -r requirements.txt

# Run the development server
uvicorn main:app --reload --port 8000

Open your browser and navigate to http://localhost:8000/docs to view the interactive Swagger documentation.

šŸ”„ CI/CD Pipeline Workflow

The pipeline defined in the Jenkinsfile automates the entire software delivery lifecycle through the following stages:

  1. Checkout SCM: Pulls the latest source code from the GitHub repository.
  2. Run Tests: Executes automated pytest suites to validate application logic.
  3. Build Docker Image: Packages the FastAPI application into a lightweight, optimized Docker container.
  4. Deploy Container: Automatically stops any legacy container instances and boots up the fresh build on port 8000.
  5. Health Check: Executes an automated internal validation probe (docker exec) targeting the /health endpoint to guarantee the application initialised successfully and is ready to accept production traffic.
  6. Post Execution (always): Automatically triggers a clean-up step (docker image prune) to keep the host disk free of dangling build cache images.

šŸ“ø Screenshots & Demo

1. Jenkins Pipeline Execution Success

Screenshot 2026-07-21 at 19 43 48

2. FastAPI Interactive Swagger Documentation

Screenshot 2026-07-21 at 19 46 08

3. Jenkins Health Check

Screenshot 2026-07-21 at 19 56 39

About

Lightweight Python FastAPI microservice with automated pytest testing, Docker containerization, and a fully automated Jenkins CI/CD deployment pipeline.

Topics

cicddockerfastapijenkinspytestpython

Resources

Readme
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Ɨ600. No cookies required.