✅Table of Content
✅Introduction
✅Day-28 Recap: Jenkins CI/CD.
✅Tasks:
✅Task-1:
Fork the repository:
Create a connection to your Jenkins job and your GitHub Repository via GitHub Integration.
GitHub Web Hooks and make sure you have CICD setup
✅Task-2:
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:)
✅Introduction:
Hello passionate DevOps engineers! In today's blog, we're diving into an exciting project focused on Jenkins and Docker Compose—two essential tools for automating and streamlining your development and deployment processes. This hands-on task will help you set up a Continuous Integration/Continuous Deployment (CI/CD) pipeline and run your application in Docker containers.
✅Day-28 Recap: Jenkins CI/CD.
Before delving into the project, let's review the principles explored in Day 28. Jenkins stands as a popular open-source automation server facilitating CI/CD workflows. It empowers developers to automate diverse phases of the software development cycle, encompassing building, testing, and deploying applications. Core topics encompass:
Installation of Jenkins on a server.
Establishment of Jenkins jobs for task automation.
Integration of Jenkins with GitHub for version control.
Configuration of webhooks to initiate Jenkins builds in response to code alterations.
✅Tasks:
✅Task-1:
Fork the repository:
Create a connection to your Jenkins job and your GitHub Repository via GitHub Integration.
GitHub Web Hooks and make sure you have CICD setup
Repo:github.com/LondheShubham153/node-todo-cicd
Step 1: Connect Jenkins to GitHub
Fork the Repository:
Go to the GitHub repository.
Click the "Fork" button on the top right to create your own copy of the repository. This is where you'll make changes.
Link Jenkins with GitHub:
Open your Jenkins dashboard.
Go to your Jenkins job configuration (click on the job you want to configure, then click on "Configure").
Find the "Source Code Management" section and select "Git".
Enter your GitHub repository URL in the "Repository URL" field.
Save your changes by clicking "Save" or "Apply".
Set Up GitHub Webhooks:
Go to your GitHub repository and click on "Settings".
In the left sidebar, select "Webhooks".
Click "Add webhook".
In the "Payload URL" field, enter the URL of your Jenkins server's webhook endpoint (you can find this URL in your Jenkins job's configuration under "Build Triggers").
Choose "application/json" as the content type.
Select the events you want to trigger the webhook (e.g., "Just the push event").
Click "Add webhook" to save.
Verify CI/CD Setup:
Make a change to your code in the forked GitHub repository.
Push the changes to GitHub.
Check Jenkins to see if it automatically starts a build when you push changes. Ensure the build completes successfully.
Now your Jenkins job is connected to your GitHub repository via GitHub integration, and CI/CD is set up with GitHub Webhooks. You're all set to automate your CI/CD pipeline for the node-todo-cicd project!
✅Task-2:
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:)
Create a Docker Compose File:
Open a text editor and create a new file named
docker-compose.yml
.Define the services for your app. Here’s a basic example to get you started:
version: '3.8' services: app: image: node:latest ports: - "3000:3000" volumes: - .:/app environment: - NODE_ENV=development command: npm start
Save the file in the root directory of your project.
Run the Application:
Open a terminal and navigate to the directory where your
docker-compose.yml
file is located.Run the command:
docker-compose up -d
. This command will start your application in the background.
Verify Everything:
- Open your web browser and go to localhost:3000 to see if your Node.js application is running properly.
😊Conclusion:
You've successfully set up a CI/CD pipeline with Jenkins and Docker Compose. Your Jenkins job is now connected to GitHub and automatically builds your code, and your application is running smoothly using Docker Compose. Great job and keep up the good work! 🎉🚀
Happy Learning :)😊