đź› Day 25 - Complete Jenkins CI/CD Project - Continued with Documentation

đź› Day 25 - Complete Jenkins CI/CD Project - Continued with Documentation

In this guide, we will see the steps to establish an automated CI/CD pipeline for a Node.js application using AWS EC2, Docker, GitHub, and Jenkins.

Quick Setup Guide 🚀

  • AWS EC2 instance

  • Jenkins installed on the machine

  • Docker and Docker-compose installed

  • GitHub account

  • GitHub integration plugin installed in Jenkins

đź—ťInstallation:

  1. Launch EC2 Instance: Create an AWS EC2 instance and give the necessary permissions which will need to run the application.

  2. Install Jenkins, Docker, and Docker-compose: Refer to the provided official Documentation of jenkins and docker 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/ This payload url is the jenkins url which we are using to access jenkins.

  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 option to use GitHub hook trigger for GITScm polling this will create auto CI/CD when any changes triggered on our repo.

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

      docker-compose down
      docker-compose up -d --build <service_name>
    
    • Verify the webhook connection by checking for a green checkmark in the GitHub repo setting webhook.

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.

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.

đź“šHappy Learning:)

Did you find this article valuable?

Support Vivek's Blog by becoming a sponsor. Any amount is appreciated!

Â