#Day24 : Day 24 Task: Complete Jenkins CI/CD Project

#Day24 : Day 24 Task: Complete Jenkins CI/CD Project

ยท

2 min read

Table of contents

Let's make a beautiful CI/CD Pipeline for your Node JS Application ๐Ÿ˜

Day 23 was all about Jenkins CI/CD, make sure you have done it and understanding the concepts.

As we have worked with Docker and Docker compose, it will be good if we use it in a live project.

Task-01

  • Fork node-todo-cicd repository:

  • Create a connection to your Jenkins job and your GitHub Repository via GitHub Integration.

  • Read About GitHub WebHooks and make sure you have CICD setup

Go to the https://github.com/LondheShubham153/node-todo-cicd.git and fork the repository.

In the previous blog, we have already created a freestyle project called first-Jenkins-project. Let's make some modifications to the same.

Select Github project and provide link for the github project.

In source-code management, select Git and give URL and give credentials ubuntu (dev-key)

and specify branch

In build triggers, select "GitHub hook trigger for GITScm polling"

What is a Github webhook?

Webhooks allow you to build or set up integrations, such as GitHub Apps or OAuth Apps, which subscribe to certain events on GitHub.com. When one of those events is triggered, a HTTP POST payload will be sent to the webhook's configured URL.

When changes are made in any file in Github, a it will automatically trigger a build in the jenkins, hence providing continuous deployment.

Task-02

  • In the Execute shell run the application using Docker compose

  • You will have to make a Docker Compose file for this Project (Can be a good open source contribution)

  • Run the project and give yourself a treat:)

Previously, we used docker build and docker run commands as separate commands.

However in this hands-on, we will create a docker-compose file and run it via jenkins.

To create a docker-compose file, first of all git clone the app files on your agent server from github using

git clone <github url>

You will get the file in your directory.

Go inside the node-todo-cicd using cd node-todo-cicd and delete the docker file as we will be building it again from scratch.

So delete the existing docker-file first.

Create a docker-file.yaml file and type the following YAML script inside it -

version : '3.9'

services:
  web:
   image: trainwithshubham/node-todo-app-cicd:latest
   ports:
     - "8000:8000"

Now go to the jenkins execute shell command and type the following

cd /home/ubuntu/projects/node-todo-cicd

docker compose down

docker compose up -d

Save the project and click on build now

Paste the private ip of the agent server with port 8000 and check whether it is working -

http://44.203.156.50:8000

The website will be up and running.

You can see the console output as well.

ย