Skip to content

This project demonstrates a DevOps pipeline for a Python Flask application that is: 🐳 Dockerized for consistent environment and deployment. πŸ” Scanned with Trivy to generate SBOM (Software Bill of Materials) and vulnerability reports. πŸ“‘ Logs forwarded to Loki using Promtail for centralized log management. πŸ“Š Visualized with Grafana

Notifications You must be signed in to change notification settings

adharsh277/flasktrivylokidemo

Repository files navigation

flasktrivylokidemo

🐍 Flask App with Trivy, Loki, Promtail & GitHub Actions CI/CD

Docker Trivy Loki Promtail CI/CD Python


πŸ“Œ Project Overview

This project demonstrates a DevOps pipeline that integrates:

  • βœ… Flask app containerized with Docker
  • βœ… Trivy scanning for vulnerabilities & SBOM
  • βœ… Promtail β†’ Loki pipeline for log collection
  • βœ… GitHub Actions CI/CD to build & push images

It provides a mini end-to-end setup for secure, observable, and automated deployments.


πŸš€ What I Learned

  • βš™οΈ Dockerization of Flask applications
  • πŸ” Image scanning & SBOM generation using Trivy
  • πŸ“œ Log aggregation pipeline with Promtail + Loki
  • πŸ” CI/CD automation using GitHub Actions workflows
  • πŸ“‚ Infrastructure as Code with docker-compose & YAML
  • 🐍 Python web development with logging to files

🧰 Tech Stack

Layer Tools / Tech
Backend App Python (Flask)
Security Trivy (SBOM + vulnerability scan)
Log Forwarding Promtail
Log Aggregation Loki
Containerization Docker, Docker Compose
CI/CD GitHub Actions
Source Control Git, GitHub
DevOps Skills CI/CD, Observability, Security, YAML

πŸ—οΈ Project Structure

flasktrivylokidemo/ β”œβ”€β”€ app.py # Flask application β”œβ”€β”€ Dockerfile # Flask app Dockerfile β”œβ”€β”€ docker-compose.yml # Multi-service setup (Flask, Loki, Promtail) β”œβ”€β”€ promtail-config.yaml # Promtail log forwarder config β”œβ”€β”€ loki-config.yml # Loki configuration β”œβ”€β”€ .github/ β”‚ └── workflows/ β”‚ └── gitworkflow.yml # GitHub Actions pipeline β”œβ”€β”€ requirements.txt # Flask dependencies └── README.md

⚑ CI/CD Pipeline

GitHub Actions workflow automates:

  1. Build Docker image of Flask app
  2. Scan image with Trivy (optional extension)
  3. Push to Docker Hub automatically

▢️ Running Locally

  1. Clone the repo:
    git clone https://github.com/<your-username>/flasktrivylokidemo.git
    cd flasktrivylokidemo

Start services:

bash Copy Edit docker-compose up -d Access:

Flask app β†’ http://localhost:5000

Loki API β†’ http://localhost:3100

πŸ“Š Future Improvements Add Grafana dashboards for Loki logs

Extend Trivy scans with GitHub Action reports

Deploy to Kubernetes for scaling

About

This project demonstrates a DevOps pipeline for a Python Flask application that is: 🐳 Dockerized for consistent environment and deployment. πŸ” Scanned with Trivy to generate SBOM (Software Bill of Materials) and vulnerability reports. πŸ“‘ Logs forwarded to Loki using Promtail for centralized log management. πŸ“Š Visualized with Grafana

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published