Skip to main content

Command Palette

Search for a command to run...

Day 24 Task: Complete Jenkins CI/CD Project

Published
β€’3 min read
Day 24 Task: Complete Jenkins CI/CD Project
P

Greetings! πŸ‘‹ I'm Priyadarshi Ranjan, a dedicated DevOps Engineer embarking on an enriching journey. Join me as I delve into the dynamic realms of cloud computing and DevOps through insightful blogs and updates. πŸ› οΈ My focus? Harnessing AWS services, optimizing CI/CD pipelines, and mastering infrastructure as code. Whether you're peers, interns, or curious learners, let's thrive together in the vibrant DevOps ecosystem. 🌐 Connect with me for engaging discussions, shared insights, and mutual growth opportunities. Let's embrace the learning curve and excel in the dynamic realm of AWS and DevOps technology!

Let's Make a Beautiful CI/CD Pipeline for Your Node.js Application 😍

Introduction

Welcome to Day 24! Today, we're going to create a full-fledged CI/CD pipeline for a Node.js application using Jenkins and Docker. By the end of this project, you'll have a hands-on project to showcase on your resume. Before diving in, ensure you have a good understanding of Jenkins from Day 23. If not, review the concepts before proceeding.

Task 01: Setting Up Your Repository and Jenkins Job

  1. Fork the Repository

    • Start by forking the repository you'll be working on. This can be your own Node.js application or a sample project.
  2. Create a Connection Between Jenkins and GitHub

    • Go to Jenkins and navigate to your job configuration.

    • Under the "Source Code Management" section, select "Git" and enter your repository URL.

    • Configure GitHub integration by adding your GitHub credentials under "Credentials".

  3. GitHub WebHooks

    • WebHooks are essential for triggering Jenkins jobs automatically when changes are pushed to the repository.

    • Go to your GitHub repository settings and select "Webhooks".

    • Add a new WebHook with the payload URL pointing to your Jenkins server (e.g., http://your-jenkins-server/github-webhook/).

    • Set the Content type to application/json.

  4. Refer to This Video for the Entire Project

Task 02: Running the Application Using Docker Compose

  1. Create a Docker Compose File

    • Docker Compose allows you to define and run multi-container Docker applications.

    • Create a docker-compose.yml file in your project root directory. Here’s a basic example for a Node.js application:

        version: '3.9'
        services:
          app:
            image: node:14
            working_dir: /app
            volumes:
              - ./app
            ports:
              - '3000:3000'
            command: npm start
      
  2. Configure Jenkins to Run Docker Compose

    • In your Jenkins job configuration, scroll down to the "Build" section.

    • Add a "Execute shell" build step.

    • In the shell command, add the following:

        docker-compose up --build -d
      
  3. Run the Project and Celebrate

    • Save your Jenkins job configuration and trigger a build.

    • Once the build is successful, your application should be running, and you can access it via http://localhost:3000.

Real-Life Example

Imagine you are part of a development team working on a Node.js e-commerce application. Every time you or a team member pushes code to the repository, you want Jenkins to automatically pull the changes, build the Docker images, and deploy the application. This ensures that the latest code is always running and ready for testing or production.

Conclusion

By completing this task, you have successfully set up a CI/CD pipeline for your Node.js application using Jenkins and Docker Compose. This project not only helps automate your development process but also enhances your resume with hands-on experience in modern DevOps practices.

Feel free to explore more features and improve your pipeline. Happy coding and deploying! πŸš€

More from this blog

Priyadarshi Ranjan

71 posts

As a DevOps engineer, I leverage automation and continuous integration to streamline development workflows, ensuring robust and scalable deployments.