This project demonstrates a professional-grade DevOps workflow for a Node.js application. It covers everything from source code management to automated testing, containerization, and continuous deployment using Jenkins.
- Application: Simple Node.js Express server with a modern, responsive UI.
- Source Control: GitHub integration with structured branching and commit history.
- CI/CD Pipeline: Automated Jenkins pipeline (Checkout → Install → Test → Build → Deploy).
- Containerization: Fully Dockerized application for consistent environments.
- Automated Testing: Unit tests implemented with Jest.
| Category | Tool |
|---|---|
| Language | Node.js |
| Web Framework | Express |
| Testing | Jest |
| Version Control | Git / GitHub |
| CI/CD | Jenkins |
| Containerization | Docker |
# Install dependencies
npm install
# Run the app locally
npm run devThe app will be available at http://localhost:3000.
# Build the Docker image
docker build -t devops-demo:latest .
# Run the application in a container
docker run -p 3000:3000 devops-demo:latestThe Jenkinsfile in this repository automates the following stages:
- Checkout: Pulls the latest code from GitHub.
- Install: Installs dependencies using
npm install. - Test: Runs automated Jest tests. If any test fails, the build stops.
- Build Docker Image: Builds a fresh Docker image from the latest code.
- Deploy: Runs the newly built container (simulating deployment).
- Code Commit: A developer pushes code to the
devormainbranch on GitHub. - Trigger: GitHub sends a webhook notification to the Jenkins server.
- Pipeline Execution: Jenkins automatically starts the pipeline defined in the
Jenkinsfile. - Verification: The code is tested and validated.
- Artifact Creation: A Docker image is created, ensuring the app is packaged with all its dependencies.
- Delivery: The application is updated automatically, reducing manual errors and downtime.
To set up the automated trigger:
- Go to your GitHub Repository Settings > Webhooks.
- Add your Jenkins URL (e.g.,
http://your-jenkins-url/github-webhook/). - In Jenkins, create a Pipeline Job and point it to your repository URL.
- Enable "GitHub hook trigger for GITScm polling" in the job configuration.
main: Production-ready code.dev: Development and integration branch.feature/*: Specific feature development branches.
MIT