🛠Day 25 - Complete Jenkins CI/CD Project - Continued with Documentation

🛠Day 25 - Complete Jenkins CI/CD Project - Continued with Documentation

Continuous Integration (CI) and Continuous Deployment (CD) are pivotal in modern software development, ensuring the swift and dependable delivery of applications. In this guide, we will outline the steps to establish an automated CI/CD pipeline for a Node.js application using AWS EC2, Docker, GitHub, and Jenkins.

🕹Getting Started: Ensure you have the following prerequisites ready

  • AWS EC2 instance

  • Jenkins installed

  • Docker and Docker-compose installed

  • GitHub account

  • GitHub integration plugin installed in Jenkins

🗝Installation:

  1. Launch EC2 Instance: Initiate an AWS EC2 instance and verify that you have the necessary permissions.

  2. Install Jenkins, Docker, and Docker-compose: Refer to the provided links for guidance on installing Jenkins, Docker, and Docker-compose.

  3. Fork and Clone Repository: Clone the repository onto your EC2 instance using the following commands:
    git clone <repository_url>

  4. Create SSH Keys: Generate SSH public and private keys on your EC2 instance:
    ssh-keygen
    cd .ssh
    cat id_rsa
    cat id_rsa.pub

  5. Configuring GitHub: In GitHub, navigate to Account Settings, click on SSH and GPG keys, and add the public IP of your EC2 instance.

  6. Configure GitHub Webhook: In your repository settings, click on Webhooks, add a webhook with the Jenkins environment URL, and set the payload URL to http://your-jenkins-ip/github-webhook/.

  7. Configuring Jenkins: Install the GitHub integration plugin in Jenkins. Create a freestyle project, configure the GitHub project URL, and set up the Git repository credentials.

🗡️Jenkins CI/CD Pipeline Steps:

  • Configure the build trigger to use GitHub hook trigger for GITScm polling.

  • Set up build steps using Docker-compose commands to build and deploy the Node.js application.
    Example Build Steps:

echo "starting container"
docker-compose down
docker-compose up -d --no-deps --build <service_name>
  • Verify the webhook connection by checking for a green checkmark in the GitHub project.

  • Run the Pipeline: Access the Jenkins dashboard, click on the project, and build the project to trigger the CI/CD pipeline.

Accessing the Application: Access the application at http://public_ip_of_instance:8000 in a web browser.

Usage: Upon completing the setup, any changes pushed to the GitHub main branch will automatically trigger the Jenkins pipeline. Monitor the Jenkins dashboard for build statuses and access the deployed application to verify the changes.

Contributing: Contributions to this project are welcome. Follow these steps to suggest enhancements or bug fixes:

  1. Fork the project.

  2. Create a new branch for your feature (e.g., git checkout -b feature/AmazingFeature).

  3. Commit your changes (git commit -m 'Add some AmazingFeature').

  4. Push to the branch (git push origin feature/AmazingFeature).

  5. Open a Pull Request.

Your contributions are highly appreciated in enhancing the robustness and efficiency of this CI/CD pipeline.

I'm confident that this blog will prove to be a valuable resource, offering fresh insights and enriching your learning experience.

Thank you for reading!😊

Did you find this article valuable?

Support Pratik R. Mandge by becoming a sponsor. Any amount is appreciated!