- Overview
- Architecture
- Technology Stack
- CI/CD Pipeline Architecture
- Getting Started
- Jenkins Setup
- Deployment
- Monitoring
- Troubleshooting
- License
This project is a comprehensive DevOps learning resource designed to demonstrate advanced CI/CD concepts, infrastructure automation, and containerization. It showcases a modern web application stack deployed through a robust, chained Jenkins pipeline architecture.
Live Demo: https://devops2.himanmanduja.fun
GitHub Repository: https://github.com/HimanM/DevOps-Project-2
Docker Hub:
- Frontend: himanm/devops-project-2-frontend
- Backend: himanm/devops-project-2-backend
The project implements a multi-stage CI/CD pipeline with automated infrastructure provisioning and deployment.
- Code Push: Developer commits code to GitHub repository.
- CI Pipeline (DevOps-CI): Jenkins detects changes, runs linting and tests, builds Docker images, and pushes to Docker Hub.
- CD Trigger: Successful CI build automatically triggers the CD pipeline.
- CD Pipeline (DevOps-CD): Jenkins connects to VPS via SSH, pulls latest images, and restarts containers.
- Infrastructure Setup (DevOps-InitDomain): Ansible configures Nginx reverse proxy and SSL certificates.
- Framework: Next.js 14 (React)
- Styling: Tailwind CSS, Shadcn UI
- Animation: Framer Motion
- Deployment: Docker container (port 3000)
- Framework: Python Flask
- API: RESTful endpoints with Prometheus metrics
- Deployment: Docker container (port 5000)
- Containerization: Docker, Docker Compose
- Reverse Proxy: Nginx (port 80 → 57002)
- SSL: Let's Encrypt (Certbot)
- CI/CD: Jenkins (chained pipelines)
- Configuration Management: Ansible
- Monitoring: Prometheus, Grafana
This project uses a chained pipeline architecture with three distinct Jenkins jobs.
Purpose: Continuous Integration - builds and publishes Docker images.
Trigger: GitHub webhook on push to main branch.
Stages:
- Checkout: Pulls source code from GitHub.
- Code Quality: Runs ESLint on frontend code.
- Unit Tests: Executes pytest for backend validation.
- Build Docker Images: Builds frontend and backend containers.
- Push to DockerHub: Publishes images to Docker Hub registry.
- Trigger CD: Automatically triggers DevOps-CD on success.
Jenkinsfile Path: Jenkinsfile
Purpose: Continuous Deployment - deploys application to production VPS.
Trigger: Upstream job (DevOps-CI) success.
Stages:
- SSH Connection: Establishes connection to VPS.
- Prepare Environment: Creates project directory structure.
- Pull Images: Downloads latest Docker images from registry.
- Deploy: Executes
docker compose up -dto restart services.
Jenkinsfile Path: Jenkinsfile.deploy
Purpose: Infrastructure as Code - configures web server and SSL.
Trigger: Manual (one-time setup or domain changes).
Stages:
- Install Ansible: Ensures Ansible is available on Jenkins agent.
- Run Playbook: Executes Ansible configuration.
- Configure Nginx: Sets up reverse proxy (port 80 → 57002).
- SSL Certificates: Generates Let's Encrypt certificates for HTTPS.
Jenkinsfile Path: Jenkinsfile.initdomain
- Docker: Version 20.10 or higher
- Docker Compose: Version 2.0 or higher
- Node.js: Version 18 or higher (for local frontend development)
- Python: Version 3.9 or higher (for local backend development)
-
Clone the repository:
git clone https://github.com/HimanM/DevOps-Project-2.git cd DevOps-Project-2 -
Start services with Docker Compose:
docker compose up --build
-
Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
- Grafana Dashboard: http://localhost:3001 (admin/admin)
- Prometheus: http://localhost:9090
Follow these steps to install Jenkins on Ubuntu/Debian systems.
Important: The Jenkins machine must have Node.js (npm) and Python (pip) installed to run frontend linting and backend tests in the CI pipeline. These are installed in Steps 2 and 3 below.
Jenkins requires Java Runtime Environment. OpenJDK 17 is recommended.
sudo apt update
sudo apt install fontconfig openjdk-17-jre
java -versionRequired for frontend linting in the CI pipeline.
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v
npm -vRequired for backend testing in the CI pipeline.
sudo apt install python3 python3-pip -y
python3 --version
pip3 --versionsudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/" | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/nullsudo apt-get update
sudo apt-get install jenkinssudo systemctl enable jenkins
sudo systemctl start jenkins
sudo systemctl status jenkinsRetrieve the initial admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPasswordNavigate to http://<your-server-ip>:8080 and enter the password to complete setup.
Navigate to Manage Jenkins > Plugins > Available Plugins and install the following:
| Plugin Name | Purpose |
|---|---|
| Docker | Build and manage Docker containers |
| Docker Pipeline | Use Docker commands in pipeline scripts |
| NodeJS | Provides Node.js and npm for frontend linting |
| Pipeline: Stage View | Visualize pipeline execution stages |
| Ansible | Execute Ansible playbooks (optional) |
After installation, restart Jenkins if prompted.
Navigate to Manage Jenkins > Credentials > System > Global credentials (unrestricted).
Create the following credentials:
| ID | Kind | Description | Example Value |
|---|---|---|---|
dockerhub-username |
Username with password | Docker Hub authentication | Username: himanmPassword: <access-token> |
vps-credentials |
Username with password | VPS SSH access | Username: rootPassword: <server-password> |
vps-ip |
Secret text | VPS IP address | 165.22.54.216 |
DEVOPS2_DOMAIN |
Secret text | Domain name | devops2.himanmanduja.fun |
Important Notes:
- For Docker Hub, use an Access Token instead of your password. Generate one at Docker Hub Security Settings.
- Ensure the VPS user has Docker permissions:
sudo usermod -aG docker <username>
- Click New Item in Jenkins dashboard.
- Enter name:
DevOps-CI - Select Pipeline and click OK.
- Under Pipeline section:
- Definition: Pipeline script from SCM
- SCM: Git
- Repository URL:
https://github.com/HimanM/DevOps-Project-2.git - Branch:
*/main - Script Path:
Jenkinsfile
- Click Save.
- Click New Item in Jenkins dashboard.
- Enter name:
DevOps-CD - Select Pipeline and click OK.
- Under Build Triggers:
- Check Build after other projects are built
- Projects to watch:
DevOps-CI - Trigger only if build is stable
- Under Pipeline section:
- Definition: Pipeline script from SCM
- SCM: Git
- Repository URL:
https://github.com/HimanM/DevOps-Project-2.git - Branch:
*/main - Script Path:
Jenkinsfile.deploy
- Click Save.
- Click New Item in Jenkins dashboard.
- Enter name:
DevOps-InitDomain - Select Pipeline and click OK.
- Under Pipeline section:
- Definition: Pipeline script from SCM
- SCM: Git
- Repository URL:
https://github.com/HimanM/DevOps-Project-2.git - Branch:
*/main - Script Path:
Jenkinsfile.initdomain
- Click Save.
-
Run Infrastructure Pipeline:
- Manually trigger
DevOps-InitDomainjob. - This configures Nginx and SSL certificates (one-time setup).
- Manually trigger
-
Trigger CI Pipeline:
- Push code to GitHub repository, or
- Manually trigger
DevOps-CIjob.
-
Automatic Deployment:
- Upon successful CI build,
DevOps-CDautomatically deploys to VPS.
- Upon successful CI build,
After deployment, verify the application:
# SSH into VPS
ssh root@<vps-ip>
# Check running containers
docker ps
# View logs
docker logs devops-project-2-frontend-1
docker logs devops-project-2-backend-1The project includes a pre-configured monitoring stack.
- URL:
http://<vps-ip>:9090 - Configuration:
monitoring/prometheus.yml - Metrics Endpoint: Backend exposes metrics at
/metrics
- URL:
http://<vps-ip>:3001 - Default Credentials:
admin/admin - Data Source: Pre-configured Prometheus connection
- Dashboards: Import from
monitoring/grafana/dashboards/
Error: permission denied while trying to connect to the Docker daemon socket
Solution:
sudo usermod -aG docker jenkins
sudo systemctl restart jenkinsError: Host key verification failed
Solution: The pipelines use -o StrictHostKeyChecking=no to bypass this. If issues persist, manually SSH once:
ssh root@<vps-ip>Error: Nginx returns 502 error
Solution:
# Check if backend container is running
docker ps | grep backend
# Check backend logs
docker logs devops-project-2-backend-1
# Restart containers
cd ~/devops-project-2
docker compose restartError: EACCES: permission denied
Solution: Ensure Jenkins agent has Node.js installed or use Docker agent in Jenkinsfile.
This project is for educational purposes. Feel free to use and modify for learning.
Author: HimanM
Repository: github.com/HimanM/DevOps-Project-2
Live Demo: devops2.himanmanduja.fun






