☑️Day 71: Project – Django To-Do List🚀
🔹Table of Contents :
Introduction
Tasks Performed
Docker Installation and Configuration
Jenkins Installation and Setup
Integrating Jenkins with Docker
Key Insights Gained
Conclusion
Today, I made significant progress in completing the next steps of the Django To-Do List project. Here’s what I achieved:
✅Tasks Performed:
1. Cloning Code from GitHub to EC2 Instance
- Cloned the Django To-Do List project repository from GitHub to the EC2 instance.
git clone <repository_url>
cd <repository_directory>
2. Setting Up Python and Running the Project
- Installed Python3 and required libraries:
sudo apt update
sudo apt install python3 python3-pip -y
pip install -r requirements.txt
- Performed migrations:
python3 manage.py migrate
- Ran the server:
python3 manage.py runserver 0.0.0.0:8001
3. Changing Inbound Rules on AWS
Updated Security Group Inbound Rules to allow traffic for port
8001
.Protocol: TCP
Port Range: 8001
Source: 0.0.0.0/0
4. Installing Docker and Creating Dockerfile
- Installed Docker.io:
sudo apt install docker.io -y
sudo systemctl start docker
sudo systemctl enable docker
✅Created Dockerfile in the project directory:
FROM python:3.9
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8001"]
EXPOSE 8001
✅5. Installing Jenkins
- Updated the system and installed Java:
sudo apt update
sudo apt install openjdk-11-jdk -y
java -version
- Installed Jenkins:
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins
Access Jenkins:
URL:
http://<EC2_Public_IP>:8080
Retrieved the initial admin password:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
✅6. Integrating Jenkins with the Dockerfile
Created a Jenkins Pipeline:
- Configured a new pipeline to build the Docker image and run the container.
Jenkinsfile for Pipeline:
pipeline {
agent any
stages {
stage('Clone Repository') {
steps {
git 'https://github.com/<repository_url>'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t django-todo . '
}
}
stage('Run Docker Container') {
steps {
sh 'docker run -d -p 8001:8001 django-todo'
}
}
}
}
✅Key Insights Gained Today:
Code Deployment on EC2: Successfully ran the Django project on EC2 after configuring Python and installing dependencies.
Security Rules: Modified AWS inbound rules to allow external access to the Django server.
Containerization: Created a Dockerfile to containerize the application for portability and scalability.
CI/CD Pipeline: Jenkins pipeline was integrated with the project to automate Docker image creation and container deployment.
By automating these processes, the project aligns with modern DevOps practices, emphasizing efficiency and scalability. Looking forward to taking the project further tomorrow!
Stay tuned for updates on this exciting project journey! 🚀
🚀Thanks for joining me on Day 71! Let’s keep learning and growing together!
Happy Learning! 😊
#90DaysOfDevOps
Subscribe to my newsletter
Read articles from Kedar Pattanshetti directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by