This project demonstrates a simple CI/CD pipeline using GitLab CI/CD for a Node.js web application. The pipeline includes testing, building a Docker image, and deploying to a Kubernetes cluster.
app.js
: A simple Express.js web applicationtest/app.test.js
: Unit tests for the applicationDockerfile
: Instructions for building the application container.gitlab-ci.yml
: GitLab CI/CD pipeline configurationkubernetes/deployment.yml
: Kubernetes deployment configuration
The pipeline consists of three stages:
- Test: Runs unit tests for the application
- Build: Builds a Docker image and pushes it to the GitLab Container Registry
- Deploy: Deploys the application to a Kubernetes cluster (staging environment)
- GitLab account and project
- Kubernetes cluster (e.g., Google Kubernetes Engine, Amazon EKS, or Minikube for local development)
- GitLab Runner with Docker executor
- Push this project to your GitLab repository
- Set up the following CI/CD variables in your GitLab project settings:
KUBE_URL
: Your Kubernetes cluster API URLKUBE_TOKEN
: A service account token with permissions to deploy to your cluster
- Ensure your GitLab Runner is configured and running
- Trigger the pipeline by pushing a commit to the
main
branch
To run the application locally:
- Install dependencies:
npm install
- Start the application:
node app.js
- Run tests:
npm test
This project is open-source and available under the MIT License.