https://github.com/harsh971/notes-app-cicd
This project focuses on automating the deployment of a Notes App. The code, stored on GitHub, is cloned, a Docker image is created and pushed to Docker Hub, and then the application is hosted.
https://github.com/harsh971/notes-app-cicd
cicd docker docker-compose dockerhub jenkins
Last synced: about 2 months ago
JSON representation
This project focuses on automating the deployment of a Notes App. The code, stored on GitHub, is cloned, a Docker image is created and pushed to Docker Hub, and then the application is hosted.
- Host: GitHub
- URL: https://github.com/harsh971/notes-app-cicd
- Owner: Harsh971
- Created: 2024-06-10T15:04:33.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-13T10:52:39.000Z (about 2 years ago)
- Last Synced: 2024-06-13T13:40:40.222Z (about 2 years ago)
- Topics: cicd, docker, docker-compose, dockerhub, jenkins
- Language: Dockerfile
- Homepage: https://harshthakkar.netlify.app/
- Size: 641 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Notes-App-CICD

## Project Overview:
This project focuses on automating the deployment of a Notes App. The code, stored on GitHub, is cloned, a Docker image is created and pushed to Docker Hub, and then the application is hosted.
## Key Steps:
1. **Code Management:**
- Stored the Notes App code on GitHub for version control and collaboration.
2. **Containerization:**
- Created a Docker image of the Notes App, ensuring a consistent and reliable environment.
3. **Image Repository:**
- Pushed the Docker image to Docker Hub for easy access and deployment.
4. **Deployment:**
- Hosted the Notes App using the Docker image.
## Troubleshooting and Learnings:
🔧 **Docker not able to connect Jenkins User:**
- **Challenge:** When running the Jenkins CI/CD pipeline, it executes as the Jenkins user, which lacks default permission to run Docker commands.
- **Solution:** Added the Jenkins user to the Docker user group to grant necessary permissions.
- ```sudo usermod -aG jenkins docker```
🔒 **Security of Credentials:**
- **Challenge:** Securely managing sensitive credentials and environment variables.
- **Solution:** Created environment variables to handle sensitive information securely within the pipeline.
⚙️ **Application Robustness:**
- **Challenge:** Encountered an "Application Port already occupied" error.
- **Solution:** Used Docker-Compose settings instead of individual Docker run commands to manage application ports efficiently and avoid conflicts.
📡 **Automated Rebuilds with GitHub Webhooks:**
- **Challenge:** Ensuring the application rebuilds automatically upon code changes.
- **Solution:** Implemented GitHub webhooks to trigger Jenkins builds whenever a new commit is pushed to the GitHub repository, ensuring the application is always up-to-date.
## Technologies Used:
- **Version Control:** GitHub
- **CI/CD Tool:** Jenkins
- **Containerization:** Docker
- **Container Orchestration:** Docker Compose
- **Image Repository:** Docker Hub
## Dockerfile :
```
FROM python:3.9
WORKDIR /app/backend
COPY requirements.txt /app/backend
RUN pip install -r requirements.txt
COPY . /app/backend
EXPOSE 8000
CMD python /app/backend/manage.py runserver 0.0.0.0:8000
```
## Jenkins Pipeline :
```
pipeline {
agent any
stages{
stage("Clone Code"){
steps {
echo "Cloning the code"
git url:"https://github.com/LondheShubham153/django-notes-app.git", branch: "main"
}
}
stage("Build"){
steps {
echo "Building the image"
sh "docker build -t my-note-app ."
}
}
stage("Push to Docker Hub"){
steps {
echo "Pushing the image to docker hub"
withCredentials([usernamePassword(credentialsId:"dockerHub",passwordVariable:"dockerHubPass",usernameVariable:"dockerHubUser")]){
sh "docker tag my-note-app ${env.dockerHubUser}/my-note-app:latest"
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPass}"
sh "docker push ${env.dockerHubUser}/my-note-app:latest"
}
}
}
stage("Deploy"){
steps {
echo "Deploying the container"
sh "docker-compose down && docker-compose up -d"
}
}
}
}
```
## Learnings:
- Ensured smooth and secure deployment processes.
- Improved my understanding of user permissions and environment variable management.
- Enhanced the robustness and reliability of Dockerized applications.
- Gained valuable experience with GitHub webhooks for automated rebuilds.
Code Source : [Click here](https://github.com/LondheShubham153/django-notes-app)
Project Reference : [Click here](https://www.google.com/search?q=shubham+londhe+cicd+declarative+pipeline&rlz=1C1CHBF_enIN1043IN1044&oq=shubham+londhe+cicd+declarative+pipeline&gs_lcrp=EgZjaHJvbWUyCwgAEEUYChg5GKAB0gEJMTY2OTVqMGo5qAIAsAIB&sourceid=chrome&ie=UTF-8#)
## Feedback
Your feedback is valuable! If you have suggestions for improving existing content or ideas for new additions, please open an issue or reach out to the repository maintainers. If you have any other feedbacks, you can reach out to us at harsh.thakkar0369@gmail.com
## Connect with Me