Introduction
In today's tech world, automation is essential for delivering scalable and reliable software. This blog post guides you through building a CI/CD pipeline for a web application using Docker, Jenkins, GitHub, and AWS.
From version control with GitHub to automating builds with Docker, managing pipelines in Jenkins, and deploying on AWS, this tutorial provides valuable insights for both DevOps enthusiasts and developers seeking to optimize their deployment workflows.
Overview
In this blog post, we’ll walk through deploying the To-Do Application via a fully automated CI/CD pipeline. The pipeline integrates GitHub for version control, Jenkins to automate the entire build and deployment process and Docker to containerize the application for consistent and portable deployments. We’ll also use AWS for hosting the application. By the end of this blog, you’ll have a seamless, scalable, and reliable deployment workflow for the To-Do application!
Tools Used
GitHub
Jenkins
Docker
AWS
Let's get started--->
Step 1: Provision an EC2 instance with the specified configuration details.
AMI: ubuntu
Instance type: t2 micro, 1 CPU, 1 GiB Memory, and ports 80, 22 are open to allow incoming traffic
Step 2: Clone the Repository
Fork this repo: https://github.com/gourilande/django-todo.git
Step 3: Install Docker and Jenkins
Install Docker
$ sudo apt-get update
$ sudo apt-get install
docker.io
Install Jenkins
sudo apt install fontconfig openjdk-17-jre
java -version
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]"
https://pkg.jenkins.io/debian-stable
binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
Step 4: Configure Inbound Rules for Jenkins and Docker
Add inbound rules to allow traffic for Jenkins on port 8080 and Docker on port 8000, with the source set to Anywhere (0.0.0.0/0) for both ports to ensure accessibility from any location.
Step 5: Write a Dockerfile inside django-todo
FROM python:3.9
RUN pip install django==3.2
COPY . .
RUN python manage.py migrate
EXPOSE 8000 CMD ["python", "manage.py","runserver","0.0.0.0:8000"]
Step 6: Go to Jenkins and create freestyle project and integrate GitHub and Jenkins
While creating credentials, select Secret Text as the credential type and enter your GitHub Personal Access Token in the secret field for secure authentication.
Now, add build steps to execute the application :
cd /home/ubuntu/project/django-todo
sudo docker build . -t todo-dev
sudo docker run -d -p 8000:8000 todo-dev
Now click on save and build now
Step 7: Testing the application
Access the To-Do application by navigating to the EC2 instance's public IP on port 8000. Ensure the application is fully functional and accessible via the specified port for proper operation.
Done!
Stay tuned for my next blog . I will keep sharing my learnings and knowledge here with you.
Let's learn together! I appreciate any comments or suggestions you may have to improve my blog content.
Thank you,
Gouri Lande.
#CloudAutomation #Jenkins #Docker #GitHub #CI_CD #DevOps #AWS #CloudDeployment #Automation #DevOpsPipeline #ContinuousDelivery #DockerContainers #JenkinsPipeline #TechBlog #AWSCloud #CI #CloudInfrastructure #DevOpsTools #SoftwareDeployment