Skip to content

DataWizual/flask-devops-tutorial

Repository files navigation

🚀 DevOps Infrastructure Template — Flask + CI/CD + Monitoring

Build Status Docker Grafana Prometheus

Production-ready DevOps environment template featuring
Flask application, GitHub Actions CI/CD pipeline, Dockerized deployment, and real-time Prometheus + Grafana monitoring.


✨ Features at a Glance

  • 🧩 Modular structure — clean separation between app, monitoring, and scripts
  • 🐳 Fully containerized — runs entirely via Docker Compose
  • 🔄 Automated CI/CD — GitHub Actions builds and pushes to Docker Hub
  • 📊 Real-time monitoring — Prometheus + Grafana + cAdvisor
  • 🚀 One-command deploy./scripts/deploy.sh
  • 🧠 Perfect for learning, demos, or production bootstrap
  • 🎨 Dark Grafana dashboard — presentation-ready visuals

🧱 Overview

A fully integrated DevOps infrastructure template including:

  • Backend demo app: Flask (flaskr)
  • CI/CD: GitHub Actions (build & push Docker image)
  • Deployment: deploy.sh — one command for updates
  • Monitoring: Prometheus + Grafana + cAdvisor
  • Config files: docker-compose.yml, prometheus.yml, and Grafana templates

📁 Project Structure (click to expand)
📦 packaged_solution
├── 🚀 app
│   ├── ⚙️ deploy.sh
│   ├── 🐳 docker-compose.yml
│   ├── 🧱 Dockerfile
│   ├── 🧩 flaskr
│   │   ├── 🔐 auth.py
│   │   ├── 📰 blog.py
│   │   ├── 🗄️ db.py
│   │   ├── 📄 __init__.py
│   │   ├── 🧾 schema.sql
│   │   ├── 🎨 static
│   │   │   └── style.css
│   │   └── 🖼️ templates
│   │       ├── 🔑 auth
│   │       │   ├── login.html
│   │       │   └── register.html
│   │       ├── 🧩 base.html
│   │       └── 📰 blog
│   │           ├── create.html
│   │           ├── index.html
│   │           └── update.html
│   ├── 📜 LICENSE.txt
│   ├── 🧾 pyproject.toml
│   ├── 📘 README.md
│   ├── 📗 README.rst
│   └── 🧪 tests
│       ├── conftest.py
│       ├── data.sql
│       ├── test_auth.py
│       ├── test_blog.py
│       ├── test_db.py
│       └── test_factory.py
├── 🧰 ci
├── 📚 docs
├── 📊 monitoring
│   ├── 🐳 docker-compose.yml
│   ├── 📈 grafana
│   └── 📡 prometheus
│       └── prometheus.yml
└── ⚙️ scripts
    └── deploy.sh

Legend

Emoji Meaning Description
📦 Root folder Main project directory
🚀 Application layer Flask app, Docker build, and dependencies
🧩 Module / Template Flask components or HTML templates
⚙️ Script / Tooling Deployment or automation scripts
🐳 Docker / Compose Container and environment configuration
🧾 Config / Manifest Application configuration or schema
🧪 Tests Pytest test cases and fixtures
📊 Monitoring stack Prometheus, Grafana, cAdvisor setup
📡 Prometheus Metrics collection and targets config
📈 Grafana Dashboards and visualization templates
📚 Docs Documentation, images, or diagrams
🧰 CI/CD GitHub Actions, pipelines, automation
📘 / 📗 / 📜 Docs & License README and license files

⚡ Quick Start (Local Setup)

1️⃣ Run the application and monitoring stack

cd ~/devops_practice/packaged_solution/monitoring
docker compose up -d

# or launch the full stack
# docker compose -f docker-compose.full.yml up -d

2️⃣ Deploy the latest image

cd ~/devops_practice/packaged_solution/scripts
./deploy.sh

3️⃣ Access points

📊 Grafana Dashboard Customization

The included dashboard (flask_monitoring_dashboard.json) is optimized for aggregated metrics from cAdvisor and Prometheus.

Legend Settings

Panel Legend Description
CPU Usage (%) {{job}} Displays Prometheus job
Memory Usage (MB) Total Aggregated container memory
Network Traffic Receive / Transmit Inbound and outbound network
Uptime Uptime Process uptime metric
Targets {{instance}} Lists monitored services

Recommended Visualization

  • Theme: Dark
  • Time range: Last 1 hour
  • Refresh interval: 5s
  • Legend placement: Table (bottom)
  • Color thresholds: 🟢 Normal • 🟡 Warning • 🔴 Critical

🧭 About

This template demonstrates a complete DevOps lifecycle — from CI/CD automation to monitoring and deployment orchestration.

Ideal for:

  • 🔍 Learning modern DevOps practices
  • 💼 Building a professional GitHub portfolio
  • 🧩 Rapid prototyping of real infrastructure setups

🏷️ Tags

devopsdockerflaskprometheusgrafanamonitoringcicdtemplate

Made with ❤️ by Eldor Zufarov

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published