I built a CI/CD pipeline for microservices using Jenkins and Docker, separating the app into frontend and backend services. This project helped me improve my skills in Git, GitHub, Jenkins, and Docker by integrating continuous testing, versioning, and deployment.
I successfully:
- Initialized the Git and GitHub repo.
- Created a CI/CD pipeline with Jenkins.
- Dockerized microservices for deployment.
- Linked GitHub with Jenkins for automation.
- Developed a basic understanding of creating APIs and connecting them with the frontend.
- Gained confidence in DevOps practices.
This project equipped me with essential skills and experience that will be valuable for real-world DevOps and software development environments.
- Set up Git and GitHub.
- Build the frontend with HTML, CSS, and JavaScript.
- Create a Node.js API that returns JSON and connect it with the frontend.
- Containerize the application using Docker.
- Test locally: access the frontend via
localhostand the API vialocalhost:3000/data. - Automate the entire process using Jenkins.
- Project Architecture
- Tools and Technologies
- Setup and Installation
- Installing Jenkins
- Installing Docker
- Installing Required Jenkins Plugins
- Microservices Structure
- Initializing the Git and GitHub Repo
- Frontend Service (HTML, CSS, JavaScript)
- Backend Service (Node.js)
- Finalizing and Pushing Changes to GitHub
- CI/CD Pipeline Implementation
- Jenkins Configuration
- Jenkinsfile Automate Process
- Docker Integration
- Testing and Validation
- Automated Testing with Jest (Backend)
- Testing in Docker Containers
- Deployment
- Dockerized Microservices on Windows
- Running the Pipeline in Jenkins
- Project Outcome
- Problems and Solution
Architecture Diagram
CI-CD Pipeline
Deployment on Docker
For this project, I used the following tools and technologies:
- Jenkins: For automating the CI/CD pipeline.
- Docker: For containerizing the application and managing microservices.
- Git: For version control and repository management.
- GitHub: For hosting the source code and Jenkins pipeline.
- Node.js: For the backend microservice.
- HTML/CSS/JavaScript: For the frontend microservice.
- Python
unittest: For automated testing of the backend microservice.
Follow these steps to set up and install the required tools:
- Download Jenkins from the official Jenkins website.
- Run the installer and follow the on-screen instructions to complete the installation.
- Open Jenkins in your web browser at
http://localhost:8080and follow the prompts to retrieve the initial admin password.
- Download Docker Desktop from the Docker website.
- Run the installer and follow the instructions to complete the installation.
- After installation, open Docker Desktop and ensure it's running.
- At the end of this document, I have outlined the problems encountered and their possible solutions.
- Open Jenkins in your web browser.
- Go to Manage Jenkins > Manage Plugins.
- In the Available tab, search for and install the following plugins:
- Docker Pipeline
- Git
- Pipeline
- After installation, restart Jenkins to ensure the plugins are loaded.
- Initializing the Git and GitHub Repo
- Went to GitHub and created a new repository (e.g.,
microservice-cicd). - Initialized it with a
README.mdfile. - Cloned it to the local machine using Git.
- Went to GitHub and created a new repository (e.g.,
- Frontend Service (HTML, CSS, JavaScript)
- Developed a responsive frontend using HTML, CSS, and JavaScript.
- The frontend connects to the backend service through RESTful APIs.
- Backend Service (Node.js)
- Built a backend service using Node.js and Express to handle API requests.
- The backend processes data and communicates with the frontend.
- Finalizing and Pushing Changes to GitHub
- Committed the final changes to the local Git repository with a descriptive message.
- Pushed the committed changes to the GitHub repository, ensuring the latest updates are reflected.
- Updated the README file with the final project details, including steps, screenshots, and outcomes.
- Jenkins Configuration
- Jenkinsfile Automate Process
- Created a Jenkinsfile to define the pipeline stages: Checkout, Build, Test, and Deploy.
- Integrated Jenkins with GitHub to trigger builds on code commits.
- Docker Integration
- Dockerized both frontend and backend services for consistent environments across development and testing.
- Used Docker Compose to manage multi-container applications. The encountered problems and their potential solutions are discussed in the end.
For automated testing of the backend microservice, I used Python’s unittest module. This module provides a framework for writing and running tests, which helps ensure that the backend code functions correctly.
- Basic Example of
unittestin Python
Here's how I used unittest to test the backend microservice:
Code is available in the Backend folder with the name test_backend.py.
-
Build Docker Images:
- Created Docker images for the frontend and backend using the Dockerfile in their respective directories.
cd frontend docker build -t frontend:latest .
cd ../backend docker build -t backend:latest .
-
Run Docker Containers:
- Launched the frontend and backend containers in detached mode, mapping appropriate ports to the host.
docker run -d -p 80:80 frontend:latest
docker run -d -p 3000:3000 backend:latest
-
Verify Running Containers:
- Verified that both containers were running by listing active containers and using dockers desktop.
docker ps
-
Access Applications:
- Frontend: Accessed via
http://localhost. - Backend: Accessed via
http://localhost:3000/data.
- Frontend: Accessed via
-
Running the Pipeline in Jenkins - Automated Build and Deploy
- Executed the CI/CD pipeline in Jenkins.
- Deployed updates automatically to the Dockerized environment upon code changes.
- Achieved a fully automated CI/CD pipeline that builds, tests, and deploys microservices.
- Deployed a robust microservices architecture using Docker and Jenkins.
- Gained practical experience in Git, GitHub, Jenkins, Docker, and microservices architecture.
Problem: Containers failed to start. Solution: Reviewed logs, fixed Dockerfile configurations, resolved port conflicts, and adjusted network settings.
Problem: Build failures. Solution: Corrected Jenkinsfile syntax, installed necessary dependencies, and updated Jenkins plugins.
Problem: Deploying outdated code. Solution: Checked repository URL and branch settings.
Problem: Tests failed. Solution: Ensured test framework and scripts were correctly configured.
Problem: Agent configuration issues. Solution: Reconfigured agents and reviewed logs.
These were some of the main issues I encountered. I utilized resources such as Stack Overflow, YouTube, and Google to resolve these errors and misconfigurations. Apart from that, This project provided a comprehensive understanding of DevOps practices, microservices, Docker, and Jenkins. I learned to automate the build, test, and deployment processes effectively, preparing me for real-world software development and DevOps roles.
















