This project demonstrates a complete CI/CD pipeline for a simple Node.js Express application using Jenkins and Docker.
ci-cd-demo/
├── app/
│ ├── server.js
│ ├── package.json
│ └── test/
│ └── test.js
├── Dockerfile
├── docker-compose.yml
├── Jenkinsfile
├── healthcheck.sh
└── README.md
The demo app is a simple Express.js server that:
- Serves "Hello World" on the root path
/ - Provides a health check endpoint
/healthreturning{"status": "healthy"}
- Navigate to the
appdirectory - Install dependencies:
npm install - Run tests:
npm test - Start the app:
npm start
- Build the Docker image:
docker build -t ci-cd-demo . - Run with Docker Compose:
docker-compose up -d - Access the app at
http://localhost:3000 - Check health:
curl http://localhost:3000/health
The Jenkinsfile defines a Declarative pipeline with the following stages:
- Build: Install npm dependencies
- Test: Run unit tests
- Package: Build Docker image
- Deploy: Deploy using Docker Compose
- Health-Check: Verify the application is healthy
To run the pipeline in Jenkins:
- Create a new pipeline job
- Point to this repository
- The pipeline will execute automatically
healthcheck.sh performs health checks by calling the /health endpoint and verifying the response. It retries up to 10 times with 5-second intervals.
- Node.js
- Docker
- Docker Compose
- Jenkins (for pipeline execution)