CI/CD ML Model Deployment

Production-grade automated pipeline deploying ML models to Google Cloud Platform with zero manual intervention, Docker containerization, and serverless infinite scaling

πŸ€– 100% Automated 🐳 Docker ☁️ GCP Cloud Run πŸ”„ GitHub Actions ♾️ Infinite Scale πŸš€ Zero Downtime
100%
Automation Rate
0
Manual Steps Required
∞
Scalability
< 5min
Deployment Time

Overview

An enterprise-grade MLOps pipeline that automates the entire journey from code commit to production deployment with comprehensive testing, containerization, and cloud-native serving

⚑

Automated CI/CD

Complete automation using GitHub Actions for continuous integration and deployment. Triggered automatically on every commit to main branch with comprehensive testing, building, and deployment stages executed in parallel for maximum efficiency.

🐳

Docker Containerization

Multi-stage Docker builds optimized for production with minimal image size. Includes model artifacts, dependencies, and serving infrastructure in a single portable container. Versioned images stored in GCP Artifact Registry.

☁️

Serverless Deployment

Deploy to GCP Cloud Run for fully managed serverless compute. Automatic scaling from zero to thousands of instances based on traffic. Pay only for what you use with per-request billing and built-in load balancing.

πŸ”’

Secure & Compliant

Enterprise security with Google Workload Identity for authentication. Secrets managed via GitHub Secrets and GCP Secret Manager. HTTPS endpoints with automatic SSL certificates and DDoS protection.

πŸ“Š

Model Versioning

Complete version control with DVC for data and models. Every deployment tagged with Git commit SHA for full traceability. Rollback capability to any previous version with single command.

🎯

Production Ready

Health checks, logging, monitoring, and error handling built-in. Fast API endpoints with automatic request validation and OpenAPI documentation. Graceful degradation and circuit breaker patterns implemented.

System Architecture

Cloud-native architecture leveraging GCP services for scalable, reliable ML model serving

graph TB subgraph "Development" DEV[Developer] --> CODE[Code Changes] CODE --> GIT[Git Push] end subgraph "CI/CD Pipeline - GitHub Actions" GIT --> TRIGGER[Workflow Trigger] TRIGGER --> TEST[Run Tests] TEST --> BUILD[Build Docker Image] BUILD --> SCAN[Security Scan] SCAN --> TAG[Tag with SHA] TAG --> PUSH[Push to Artifact Registry] end subgraph "Google Cloud Platform" PUSH --> AR[Artifact Registry] AR --> CR[Cloud Run Service] CR --> LB[Load Balancer] LB --> AUTO[Auto Scaling] AUTO --> INST[Container Instances] end subgraph "Monitoring & Ops" INST --> LOGS[Cloud Logging] INST --> METRICS[Cloud Monitoring] INST --> TRACE[Cloud Trace] end subgraph "Clients" USER[End Users] --> HTTPS[HTTPS Endpoint] HTTPS --> LB end style CODE fill:#667eea style BUILD fill:#4facfe style CR fill:#10b981 style INST fill:#f59e0b
5
GCP Services
3
CI/CD Stages
0
Downtime
99.9%
Uptime SLA

CI/CD Pipeline

Fully automated deployment workflow from code commit to production

sequenceDiagram participant Dev as Developer participant GH as GitHub participant GA as GitHub Actions participant AR as Artifact Registry participant CR as Cloud Run participant User as End Users Dev->>GH: git push origin main GH->>GA: Trigger Workflow GA->>GA: Checkout Code GA->>GA: Set up Python Environment GA->>GA: Install Dependencies GA->>GA: Run Unit Tests GA->>GA: Run Integration Tests GA->>GA: Build Docker Image GA->>GA: Security Scan (Trivy) GA->>AR: Push Image (tagged with SHA) GA->>CR: Deploy New Revision CR->>CR: Pull Image from AR CR->>CR: Start Container Instances CR->>CR: Health Check CR->>CR: Route Traffic to New Revision CR->>User: Service Live & Ready User->>CR: API Requests CR->>User: Model Predictions

Pipeline Stages

1️⃣

Build & Test

β€’ Automated testing (unit, integration)
β€’ Code quality checks (linting, formatting)
β€’ Dependency vulnerability scanning
β€’ Model validation tests
β€’ Performance benchmarking

2️⃣

Containerize

β€’ Multi-stage Docker build
β€’ Optimized layer caching
β€’ Security vulnerability scanning
β€’ Image signing & verification
β€’ Push to Artifact Registry

3️⃣

Deploy & Serve

β€’ Zero-downtime deployment
β€’ Automatic traffic routing
β€’ Health check validation
β€’ Rollback on failure
β€’ Production monitoring

Technology Stack

Built with industry-leading tools and cloud-native technologies

πŸ”„ CI/CD & Version Control

  • πŸ“¦ GitHub - Source code management
  • πŸ”„ GitHub Actions - CI/CD automation
  • πŸ“Š DVC - Data & model versioning
  • 🏷️ Git - Version control system

🐳 Containerization

  • 🐳 Docker - Container platform
  • πŸ“¦ Multi-stage builds - Optimized images
  • πŸ”’ Trivy - Security scanning

☁️ Google Cloud Platform

  • πŸš€ Cloud Run - Serverless container platform
  • πŸ“¦ Artifact Registry - Container registry
  • πŸ” Workload Identity - Authentication
  • πŸ“Š Cloud Monitoring - Observability
  • πŸ“ Cloud Logging - Log management

πŸ€– ML & API

  • ⚑ FastAPI - Modern API framework
  • 🐍 Python - Programming language
  • πŸ“Š Scikit-learn - ML library
  • πŸ”’ Pandas - Data manipulation
  • πŸ“ˆ NumPy - Numerical computing

Key Features

⚑

Instant Deployment

From git push to production in under 5 minutes. Fully automated pipeline with parallel testing, building, and deployment stages for maximum speed.

♾️

Infinite Scalability

Cloud Run automatically scales from zero to thousands of instances. Handle traffic spikes effortlessly with per-request autoscaling.

πŸ’°

Cost Optimized

Pay only for actual requests. Scale to zero when idle. No charges for idle time, making it perfect for development and staging environments.

πŸ”

Enterprise Security

Built-in DDoS protection, automatic HTTPS, Workload Identity for authentication, and vulnerability scanning at every deployment.

πŸ“Š

Full Observability

Integrated logging and monitoring with Cloud Logging and Cloud Monitoring. Track metrics, logs, and traces in real-time.

πŸ”„

Zero Downtime

Blue-green deployments with automatic traffic switching. Health checks ensure new versions are stable before routing traffic.

Getting Started

Deploy your ML model to production in minutes with this step-by-step guide

1

Clone the Repository

Get started by cloning the repository and setting up your local environment

bash
git clone https://github.com/RohitDusane/MLOps-DVC-Git-Actions.git
cd MLOps-DVC-Git-Actions
2

Set Up GCP Project

Create a new GCP project and enable required APIs

bash
# Create project
gcloud projects create YOUR_PROJECT_ID

# Enable APIs
gcloud services enable run.googleapis.com
gcloud services enable artifactregistry.googleapis.com
gcloud services enable cloudbuild.googleapis.com
3

Configure GitHub Secrets

Add GCP credentials to GitHub repository secrets for CI/CD

yaml
# Required GitHub Secrets:
GCP_PROJECT_ID: your-project-id
GCP_SA_KEY: service-account-json-key
GCP_REGION: us-central1
SERVICE_NAME: ml-model-service
4

Train Your Model

Train your ML model locally or use the provided example model

bash
# Install dependencies
pip install -r requirements.txt

# Train model
python src/train.py

# Test API locally
uvicorn app:app --reload
5

Deploy to Production

Push to main branch to trigger automatic deployment

bash
git add .
git commit -m "Deploy ML model"
git push origin main

# GitHub Actions will automatically:
# 1. Run tests
# 2. Build Docker image
# 3. Push to Artifact Registry
# 4. Deploy to Cloud Run
6

Access Your API

Once deployed, your API will be available at the Cloud Run URL

bash
# Test your deployed API
curl -X POST https://your-service-url.run.app/predict \
  -H "Content-Type: application/json" \
  -d '{"features": [1, 2, 3, 4, 5]}'

# View API documentation
open https://your-service-url.run.app/docs

🎯 Live Demo

Try out the deployed credit prediction model with real-time inference

πŸš€ Try Live Demo

Why This Architecture?

Designed for production-grade ML deployment with best practices

βš™οΈ

Full Automation

Zero manual steps from commit to production. GitHub Actions handles testing, building, scanning, and deployment automatically.

πŸ”

Quality Assurance

Automated testing, linting, and security scanning at every stage. Deployments only proceed if all checks pass.

πŸ“ˆ

Scalability

Serverless architecture scales automatically based on demand. Handle 1 request or 1 million without configuration changes.

πŸ’»

Developer Experience

Simple workflow: code, commit, push. No complex deployment procedures or manual server configuration required.

πŸ›‘οΈ

Reliability

Built-in health checks, automatic rollbacks, and zero-downtime deployments ensure your service is always available.

πŸ“Š

Observability

Comprehensive logging and monitoring with GCP's native tools. Track every request, error, and performance metric.

↑