Skip to content

VisioSphereAI/docker-release-pipeline-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Docker CI/CD Release Pipeline with GitHub Actions

πŸ“Œ Overview

This repository demonstrates a production-grade CI/CD pipeline using:

  • Docker
  • GitHub Actions
  • Artifactory (or any container registry)
  • Multi-branch strategy

It supports:

  • Feature β†’ Dev β†’ Prod promotion
  • Tag-based releases
  • Automated validation and gating
  • Release creation and notifications

🧱 Branch Strategy

Branch Purpose
main Production-ready code
dev Pre-production / staging
feature/* Feature development

πŸ”„ Workflow Overview

1️⃣ Feature Development

  • Developers push code to feature/* branches
  • PR is created to dev

2️⃣ Dev Deployment (Pre-Prod Testing)

Triggered when:

  • User selects dev environment manually

Steps:

  1. Create a Git tag
  2. Build Docker image
  3. Push image to Artifactory (dev repo)
  4. Create a pre-release
  5. Send notification (success/failure)

3️⃣ Production Promotion

Triggered when:

  • User selects prod environment
  • Provides a release tag

Validations:

  • βœ… Tag exists
  • βœ… Docker image exists in dev registry
  • βœ… Release/tag exists in GitHub

Steps:

  1. Promote Docker image (dev β†’ prod)
  2. Create GitHub Release
  3. Generate release notes
  4. Create PR (dev β†’ main)
  5. Send notification

πŸ—οΈ Repository Structure

.
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── routes.py
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ api.md
β”‚   β”œβ”€β”€ overview.md
β”‚   └── setup.md
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ run.sh
β”‚   └── test.sh
β”œβ”€β”€ tests/
β”‚   └── test_basic.py
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
└── .dockerignore

βš™οΈ GitHub Actions Workflow

πŸ”Ή Manual Trigger Inputs

Input Description
environment dev / prod
tag Required for prod

🐳 Docker Build

docker build -t <repo>:<tag> .
docker push <repo>:<tag>

πŸ§ͺ Validation Logic (Prod)

  • Check tag exists
  • Check Docker image exists
  • Check GitHub release/tag exists

Example:

./scripts/validate.sh <tag>

πŸ” Image Promotion

Instead of rebuilding:

  • Pull from dev registry
  • Retag
  • Push to prod registry
docker pull dev-repo/app:<tag>
docker tag dev-repo/app:<tag> prod-repo/app:<tag>
docker push prod-repo/app:<tag>

πŸ“’ Notifications

You can integrate:

  • Email (SMTP)
  • Slack
  • Teams

πŸ” Required Secrets

Add in GitHub Secrets:

Secret Name Description
DOCKER_USERNAME Docker registry username
DOCKER_PASSWORD Docker registry password
ARTIFACTORY_URL Registry URL
EMAIL_USERNAME SMTP username
EMAIL_PASSWORD SMTP password

πŸ“¦ Sample Workflow (Simplified)

This repository includes a GitHub Actions workflow in .github/workflows/ci.yml that:

  • checks out the code
  • installs Python dependencies
  • runs unit tests with pytest
  • builds the Docker image

🐳 Docker Compose

A docker-compose.yml file is provided for local development:

docker compose up --build

πŸ“š Documentation

Additional documentation is available in the docs/ folder:

  • docs/overview.md β€” project overview and structure
  • docs/setup.md β€” development, Docker, and test setup
  • docs/api.md β€” endpoint documentation

πŸ§ͺ Local Flask Sample Application

A simple Flask sample application is available under app/.

This version includes a multi-page site with HTML templates and CSS assets.

Run locally:

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
copy .env.example .env
set FLASK_APP=app
flask run

Visit:

  • http://127.0.0.1:5000/
  • http://127.0.0.1:5000/about
  • http://127.0.0.1:5000/contact

Build and run with Docker:

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

Run with Docker Compose:

docker compose up --build

Run tests:

pip install pytest
pytest

πŸ—‚οΈ Current Repository Structure

.
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ __init__.py
β”‚   └── routes.py
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ api.md
β”‚   β”œβ”€β”€ overview.md
β”‚   └── setup.md
β”œβ”€β”€ scripts/
β”‚   β”œβ”€β”€ run.sh
β”‚   └── test.sh
β”œβ”€β”€ tests/
β”‚   └── test_basic.py
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ README.md
β”œβ”€β”€ .dockerignore
└── .gitignore

🀝 Contribution

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

πŸ“„ License


⭐ Summary

This project demonstrates a real-world Dev β†’ Prod promotion pipeline with:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors