This CI/CD pipeline automates the process of building, testing, security scanning, and deploying a React frontend and Node.js backend application. The pipeline runs on Jenkins with the following tools:
- SonarQube: For static code analysis and code quality checks.
- Trivy: For container security and vulnerability scanning.
- Docker: To build and containerize the application.
- DockerHub: To store the built images.
- AWS: Jenkins and SonarQube instances are hosted on AWS EC2.
- Code Quality Check: Uses SonarQube to analyze code quality.
- Security Scanning: Uses Trivy to scan Docker images for vulnerabilities.
- Containerization: Uses Docker to build the React and Node.js application.
- DockerHub Push: Automatically pushes the Docker images to DockerHub after a successful build.
- Deployment: Future plans can include deployment to AWS ECS or Kubernetes.
Before setting up the pipeline, ensure you have the following:
- AWS EC2 instances running Jenkins and SonarQube, machine should be t2.medium or larger.
- Docker and DockerHub account.
- Trivy installed on Jenkins instance.
- Node.js and React source code.
- Jenkins plugins installed such as: Docker, NPM, SonarQube
The Jenkins pipeline is defined in the Jenkinsfile
and includes the following stages:
- Checkout: Pulls the code from the GitHub repository.
- Install Dependencies: Installs dependencies for both React and Node.js projects.
- Build Application: Builds the React frontend and Node.js backend.
- Code Quality Analysis: Runs SonarQube for static code analysis.
- Docker Build: Builds Docker images for both frontend and backend.
- Trivy Security Scan: Scans the built Docker images using Trivy.
- DockerHub Push: Pushes the built Docker images to DockerHub.
- Post Actions: Notifications or further actions can be configured here.