Building a DevOps Pipeline for a Todo Application Using YAML, Docker Compose, and Jenkins CI/CD

👋Hello I am Mohd Saif, passionate technology enthusiast currently pursuing a bachelor of Computer application degree.
🎓Education: I am currently pursuing a bachelor of Computer application degree with the focus on coding at Bareilly University my education journey has equipped me with strong foundation in Computer science and I am eager to apply my knowledge to real word challenges.
💡Passion for technology: I have always been deeply passionate about technology and I am particular drawn to devops with AWS.
🚀Skills: 🔹Linux 🔹Shell scripting 🔹Python 🔹Ansible 🔹Docker 🔹Kubernetes 🔹Jenkins CI/CD 🔹Maven 🔹Git and GitHub
✨Future goals: My goal is to facilitate seamless collaboration between development and operations teams, ensuring faster releases and high-quality software. I am a proactive learner, constantly exploring new DevOps trends and practices
In this blog, we'll show you how to set up a freestyle CI/CD pipeline for a simple Todo application using YAML, Docker Compose, and Jenkins. Our goal is to make the build, test, and deployment processes smooth and reliable.
Prerequisites
Before we begin, ensure you have the following installed:
Docker
Docker Compose
Jenkins
Git and GitHub
VMware terminal or AWS EC2 instances
Code Clone via GitHub
First, clone the repository from GitHub. Open your terminal and run the following command:
a) Create a directory in the terminal to store the project using the mkdir command.
b) After creating the directory, go inside it using the cd command.
c) Enter the directory, then run the git clone "repo name" command.
d) Check the cloning by using the ls command and then go inside the cloned directory using the cd command.

Install Docker Compose
To install Docker Compose,.....
a) Run the command on the Ubuntu terminal to install Docker Compose: apt-get install docker-compose.
b) Check if Docker Compose is installed by running the command: docker-compose -v.

I have already installed Docker Compose.
Docker Compose
Create a docker-compose.yml file to define our multi-container application.
a) Run the command vi docker-compose.yml.

b) Write the YAML script for the project. After writing the YAML script, press the Esc button, then type :wq and press Enter.
docker-compose.yml

c) Check if the Docker Compose file is correct by using the command: docker-compose config.

Run the to-do application
a) Run the docker-compose up command. The first time you run this command, you will see the build process, as shown in this screenshot.

b) Run the command docker-compose up again, and you will see that our application is running.

Now, let's access our to-do application using the IP address with port 8000.

Now, let's run the to-do application using a Jenkins CI/CD pipeline. But first, I need to push the code to GitHub. So, let's go ahead and push our code to GitHub.
a) Check the git status

b) Run the command git add docker-compose.yml.
c) Run the command git commit -m "message".
d) Run the command git push origin "branch name".

Now everyone can see the pushed docker-compose.yml file.

Jenkins Configuration
a) Go to "New Item" and enter the application name. Then, choose "Freestyle Project".

b) In the "General" section, provide any description you want.

c) Now, go to "Source Code Management" to enter the repository URL and branch name.

d) Now, go to the Build step, choose "Execute Shell," and enter these commands: docker-compose down and docker-compose up -d --force-recreate --no-deps --build web. After typing these commands, click "Apply" and then "Save".

e) Then click "Build Now" and watch your application build successfully.

Check the console output as well.


Our to-do DevOps project with Jenkins looks like this:
Once everything is set up, let's view our to-do application.

Guys, check out this application running with our Jenkins pipeline. It runs very smoothly and efficiently.
Conclusion
In this blog, we created a freestyle CI/CD pipeline for a simple Todo application using YAML, Docker Compose, and Jenkins. This setup helps streamline the build, test, and deployment processes, ensuring that your application is always ready to deploy. By using Jenkins and Docker, we can achieve a reliable and efficient freestyle CI/CD pipeline.
Happy DevOps-ing!
