Day 25:- Completed Jenkins CI/CD Project - Continued with Documentation

Day 25:- Completed Jenkins CI/CD Project - Continued with Documentation

Task-01

  • Document the process from cloning the repository to adding webhooks, Deployment, etc. as a README, go through this example

  • A well-written readme file will help others to understand your project and you will understand how to use the project again without any problems.

  1. Launch an EC2 instance on AWS with an Amazon Linux 2 AMI.

  2. Connect to your EC2 instance using SSH.

  3. Install Docker on your EC2 instance by running the following commands:

sudo yum update -y
sudo apt-get  install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
  1. Install Java on your system. You can download and install the latest version of Java from the official Java website.

  2.    sudo yum install java-1.8.0-openjdk -y
    
  3. Install Jenkins on your system. You can download and install the latest version of Jenkins from the official Jenkins website.

  4. Once Jenkins is installed, navigate to the Jenkins dashboard in your web browser and create a new job. Give the job a name and select "Pipeline" as the job type.

  5. Under "Pipeline", select "Pipeline script" and paste the following script:

  6.    pipeline{
           agent any
           stages{
               stage('code clone'){
                   steps{
                       git url:'https://github.com/Pooja-Vibhute283/node-todo-cicd.git', branch: 'master'
                   }
               }
               stage('build' ){
                   steps{
                     sh 'docker build . -t django-todo-app'
                   }
               }
              stage('deploy'){
                   steps{
                     sh 'docker-compose down && docker-compose up -d'
       }
       }
       }
       }
    

This script will perform the following steps:

  • It will clone your repo

  • It will build an image from the Dockerfile

  • Start the application using Docker Compose.

  1. Save the job and navigate to the job's configuration page. Under "Build triggers", select "GitHub hook trigger for GITScm polling". This will enable Jenkins to automatically trigger the pipeline whenever changes are pushed to the GitHub repository.

  2. Next, create a webhook on your GitHub repository. Navigate to the repository's settings page, select "Webhooks", and create a new webhook. Set the payload URL to http://<jenkins-host>:<jenkins-port>/GitHub-webhook/, replacing <jenkins-host> and <jenkins-port> with the hostname and port of your Jenkins server.

  3. Create a docker-compose.yml file in the root directory of your project, with the following contents:

version: '3.9'

services:
  web:
    build: .
    ports:
      - "8000:8000"

This file defines a Docker Compose service for your application, with the image name node-todo-cicd, and maps port 8000 on the host to port 8000 in the container.

  1. Commit your changes to your GitHub repository, and wait for Jenkins to automatically trigger the pipeline. You should see the pipeline stages running in the Jenkins console output.

  2. Once the pipeline has been completed successfully, your application should be deployed and accessible at http://<publicip>:8000/.

That's it! You now have a fully automated CI/CD pipeline for your Node.js application, using Docker, Java, and Jenkins.

Task-02

  • Also, it's important to keep smaller goals, as it's a small task, think of a small Goal you can accomplish.

My GOAL - To Become a DevOps Engineer

STRATEGIES-

  1. Developing a strong foundation in software development.

  2. Gain Expertise in Automation Tools and Technologies.

  3. Learn about Cloud Computing.

  4. Focus on Collaboration and Communication.

  5. Stay Current with Industry Trends.

  6. Practice Continuous Learning

NOTE TO me - Continuous learning consistently and never give up

RESULT- Becoming a DevOps engineer

THAT'S ALL FOR TODAY'S LEARNING I HOPE YOU LEARN SOMETHING FROM THIS BLOG