Task: Document the Jenkins CI/CD Project
You'll be documenting your Jenkins CI/CD project by creating a README.md file in your repository. This file will serve as a comprehensive guide to your automated workflow. Here's a structured, complete README.md
that you can copy and paste directly into your GitHub repository.
Jenkins CI/CD Project
Overview
This project demonstrates a complete CI/CD pipeline using Jenkins, GitHub Webhooks, Docker, and Docker Compose. The goal is to automate the process of building and deploying a containerized application whenever code is pushed to GitHub.
Tech Stack
- Jenkins – The CI/CD automation server that orchestrates the entire pipeline.
- GitHub – Used for source code hosting and triggering builds via webhooks.
- Docker – The containerization platform used to package the application and its dependencies.
- Docker Compose – A tool for defining and running multi-container Docker applications.
CI/CD Flow
- Push ➡️ Developer pushes code changes to GitHub.
- Webhook ➡️ GitHub immediately notifies Jenkins via a webhook.
- Build ➡️ Jenkins pulls the latest code, builds a new Docker image for the application.
- Deploy ➡️ Jenkins uses
docker-compose
to stop and remove any old containers, then starts new ones from the updated image. - Run ➡️ The application is now live and running in a containerized environment.
Step-by-Step Setup
-
Clone the Repository
git clone https://github.com/debsinthecloud/Jenkins-90days-of-devops.git cd Jenkins-90days-of-devops
-
Install Jenkins & Plugins
- Install the Jenkins LTS version on your server or local machine.
- Install the required plugins: Git, Docker, and GitHub Integration.
-
Configure GitHub Webhook
- Go to your GitHub repository:
Settings
→Webhooks
. - Add a new webhook with the following payload URL:
http://<your-jenkins-server-public-ip>:8080/github-webhook/
- Ensure the content type is
application/json
and it's triggered by theJust the push event
.
- Go to your GitHub repository:
-
Create a Jenkins Freestyle Project
- Create a new Freestyle project in Jenkins.
- Under Source Code Management, select Git and link to your repository.
- In Build Triggers, select GitHub hook trigger for GITScm polling.
-
In Build Steps, add an Execute shell step with the following script:
#!/bin/bash docker compose down docker compose build docker compose up -d
-
Verify Deployment
- Run
docker ps
on your Jenkins server to confirm the containers are running. - Access the app at
http://<jenkins-server-ip>:8000
(or your configured port).
- Run
Docker Compose Example
This project uses a docker-compose.yml
file to define and run the application's services.
version: '3.9'
services:
web:
build: .
container_name: helloapp
ports:
- "8000:3000"
restart: unless-stopped
Outcome
A fully automated CI/CD pipeline that automatically builds and deploys your application with every new code push to GitHub.
Top comments (0)