Skip to content

risecyber7-cyber/devmachine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DevOps Full-Stack Project

End-to-end DevOps implementation showcasing real-world production practices including CI/CD pipelines, containerization, cloud deployment, reverse proxy, HTTPS, monitoring, and infrastructure automation.


Project Overview

This project demonstrates an end-to-end DevOps implementation including:

  • CI/CD Pipeline - Automated build, test, and deploy with GitHub Actions
  • Dockerized Application - Multi-stage Docker builds for frontend and backend
  • Cloud Deployment - AWS EC2 with Terraform infrastructure as code
  • Reverse Proxy Setup - Nginx with load balancing and rate limiting
  • HTTPS Configuration - Let's Encrypt SSL/TLS certificates
  • Infrastructure Automation - Terraform for reproducible infrastructure
  • Monitoring - Prometheus metrics collection + Grafana dashboards

Architecture Diagram

                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Developer   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚ git push
                    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
                    β”‚    GitHub    β”‚
                    β”‚  Repository  β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚ triggers
                    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
                    β”‚GitHub Actionsβ”‚
                    β”‚   CI/CD      β”‚
                    β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”˜
                       β”‚       β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Docker   β”‚ β”‚ Container β”‚
              β”‚  Build    β”‚ β”‚ Registry  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”˜ β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚       β”‚
                    β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”
                    β”‚  AWS EC2    β”‚
                    β”‚  Instance   β”‚
                    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                    β”‚   Nginx     β”‚
                    β”‚ + SSL/HTTPS β”‚
                    β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”˜
                       β”‚       β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β” β”Œβ”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  React    β”‚ β”‚  Express  β”‚
              β”‚ Frontend  β”‚ β”‚  Backend  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                                  β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Prometheus  β†’  Grafana    β”‚
                    β”‚  (Metrics)    (Dashboards) β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Component Technology
Frontend React.js
Backend Node.js / Express
Containerization Docker
CI/CD GitHub Actions
Cloud Provider AWS EC2
Web Server Nginx
SSL Let's Encrypt
Infrastructure Terraform
Metrics Prometheus
Dashboards Grafana

Project Structure

β”œβ”€β”€ frontend/                    # React.js frontend application
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   β”œβ”€β”€ src/                     # React source code
β”‚   β”‚   β”œβ”€β”€ components/          # Reusable components
β”‚   β”‚   β”œβ”€β”€ App.js               # Main application component
β”‚   β”‚   └── index.js             # Entry point
β”‚   β”œβ”€β”€ Dockerfile               # Multi-stage frontend build
β”‚   β”œβ”€β”€ nginx.conf               # Frontend Nginx config (SPA routing)
β”‚   └── package.json
β”‚
β”œβ”€β”€ backend/                     # Node.js / Express backend API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/              # API route handlers
β”‚   β”‚   β”œβ”€β”€ __tests__/           # Unit tests
β”‚   β”‚   β”œβ”€β”€ app.js               # Express application setup
β”‚   β”‚   └── server.js            # Server entry point
β”‚   β”œβ”€β”€ Dockerfile               # Backend container build
β”‚   └── package.json
β”‚
β”œβ”€β”€ nginx/                       # Nginx reverse proxy configuration
β”‚   β”œβ”€β”€ nginx.conf               # Main Nginx config
β”‚   └── conf.d/
β”‚       └── default.conf         # Server blocks (HTTP/HTTPS)
β”‚
β”œβ”€β”€ terraform/                   # Infrastructure as Code
β”‚   β”œβ”€β”€ main.tf                  # AWS resources (EC2, SG, IAM)
β”‚   β”œβ”€β”€ variables.tf             # Input variables
β”‚   β”œβ”€β”€ outputs.tf               # Output values
β”‚   β”œβ”€β”€ user_data.sh             # EC2 bootstrap script
β”‚   └── terraform.tfvars.example # Example variable values
β”‚
β”œβ”€β”€ monitoring/                  # Monitoring stack
β”‚   β”œβ”€β”€ prometheus/
β”‚   β”‚   └── prometheus.yml       # Prometheus scrape config
β”‚   └── grafana/
β”‚       └── provisioning/        # Auto-provisioned dashboards
β”‚
β”œβ”€β”€ .github/workflows/           # CI/CD pipelines
β”‚   β”œβ”€β”€ ci.yml                   # Continuous Integration
β”‚   └── cd.yml                   # Continuous Deployment
β”‚
β”œβ”€β”€ scripts/                     # Utility scripts
β”‚   β”œβ”€β”€ setup.sh                 # Local development setup
β”‚   β”œβ”€β”€ deploy.sh                # Manual deployment script
β”‚   └── ssl-setup.sh             # SSL certificate setup
β”‚
β”œβ”€β”€ docker-compose.yml           # Production compose
β”œβ”€β”€ docker-compose.dev.yml       # Development overrides
└── .env.example                 # Environment variable template

CI/CD Pipeline Flow

1. Developer pushes code to GitHub
        β”‚
2. GitHub Actions pipeline triggers automatically
        β”‚
3. β”Œβ”€ Backend: Lint + Unit Tests
   └─ Frontend: Lint + Build
        β”‚
4. Docker images build (multi-stage)
        β”‚
5. Images pushed to GitHub Container Registry (GHCR)
        β”‚
6. Application auto-deploys on EC2 via SSH
        β”‚
7. Nginx serves the app securely over HTTPS

Security Features

  • IAM Role-Based Access Control - EC2 instance uses IAM roles (no static keys)
  • HTTPS with SSL - Let's Encrypt certificates with auto-renewal
  • Firewall Rules - Security group allows only ports 22, 80, 443
  • Security Headers - Nginx adds X-Frame-Options, CSP, XSS-Protection, etc.
  • Rate Limiting - Nginx rate limits for API and general endpoints
  • Non-Root Containers - Backend runs as non-root user inside Docker
  • Container Health Checks - Automatic container health monitoring
  • Environment Variables - Secrets managed via .env files (never committed)
  • Helmet.js - HTTP security headers for Express backend

Quick Start

Prerequisites

1. Clone Repository

git clone https://github.com/risecyber7-cyber/devmachine.git
cd devmachine

2. Configure Environment

# Copy example environment files
cp .env.example .env
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env

# Edit .env files with your values

3. Build & Run with Docker

# Production mode (all services)
docker-compose up --build -d

# Development mode (frontend + backend only)
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up --build -d

# Or use the setup script
chmod +x scripts/setup.sh
./scripts/setup.sh

4. Access Application

Service URL
Frontend http://localhost:3000
Backend http://localhost:5000
API Health http://localhost:5000/api/health
Prometheus http://localhost:9090
Grafana http://localhost:3001

AWS Deployment with Terraform

1. Configure Terraform Variables

cd terraform
cp terraform.tfvars.example terraform.tfvars
# Edit terraform.tfvars with your AWS credentials and configuration

2. Deploy Infrastructure

terraform init
terraform plan
terraform apply

3. Configure SSL

# SSH into EC2 instance
ssh -i ~/.ssh/your-key.pem ec2-user@<EC2_PUBLIC_IP>

# Run SSL setup
chmod +x scripts/ssl-setup.sh
./scripts/ssl-setup.sh your-domain.com your-email@example.com

GitHub Actions Secrets Required

Configure these secrets in your GitHub repository settings (Settings > Secrets and variables > Actions):

Secret Description
EC2_HOST EC2 instance public IP or domain
EC2_SSH_KEY Private SSH key for EC2 access
AWS_ACCESS_KEY_ID AWS access key (optional, for ECR)
AWS_SECRET_ACCESS_KEY AWS secret key (optional, for ECR)

API Endpoints

Method Endpoint Description
GET /api/health Health check status
GET /api/info Project information
GET /api/data Sample data endpoint
GET /metrics Prometheus metrics

Monitoring

Prometheus

  • Collects backend application metrics (request rates, response times, memory, CPU)
  • Scrapes metrics every 15 seconds
  • 15-day data retention

Grafana

  • Pre-configured dashboard for backend metrics
  • Default login: admin / admin (change in .env)
  • Auto-provisioned Prometheus datasource

Future Improvements

  • Kubernetes deployment (EKS)
  • Blue-Green deployment strategy
  • Auto-scaling setup with ASG
  • Centralized logging with ELK stack
  • Database integration (PostgreSQL/MongoDB)
  • Redis caching layer
  • API rate limiting with Redis
  • Automated security scanning (Trivy, Snyk)
  • Slack notifications for deployment status

Author

Keshav Kumar - Cloud & DevOps Enthusiast

LinkedIn | GitHub


License

This project is open source and available under the MIT License.

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors