Project Report of docker
Project Report of docker
Project Report of docker
1. Introduction
This project focuses on building a continuous integration and continuous delivery (CI/CD)
pipeline for a Django-based Notes application. The pipeline was designed to automate the
process of building, testing, and deploying the application using Jenkins for CI, Docker for
containerization, DockerHub for image storage and push the image, and AWS EC2 for
deployment.
2. Objectives
Automate the build and deployment process to reduce manual intervention.
Ensure consistent testing and deployment through a well-defined CI/CD pipeline.
Use containerization (Docker) for maintaining consistency across environments.
Store and manage Docker images using DockerHub.
Deploy the Django application on AWS EC2 instances.
4. Project Workflow
4.1 Source Code Management
The source code for the Notes application is hosted on GitHub. The repository is connected to
Jenkins for automation, and the Django application code is structured according to the following:
Dockerfile: Defines the environment for the Django application.
docker-compose.yml: Manages multiple services (Django, database).
Jenkinsfile: Declarative Jenkins pipeline configuration.
The CI/CD pipeline was implemented using Jenkins' Declarative Pipeline syntax and follows
these main stages:
1. Checkout Stage:
o Jenkins pulls the latest code from the GitHub repository.
o Triggers when a new commit is pushed to the repository (using a webhook).
2. Build Stage:
o Docker is used to build the application image by reading the Dockerfile.
o The image is tagged with the current build number or commit ID for traceability.
3. Test Stage:
o Automated tests are run within the Docker container to ensure that the application
functions correctly.
o Tests include unit tests for the Django application.
4. Docker Image Push Stage:
o If the tests pass, Jenkins pushes the Docker image to DockerHub.
o This ensures that the image is available for deployment.
5. Deploy Stage:
o The deployment is done on an AWS EC2 instance using Docker.
o Jenkins connects to the EC2 instance and pulls the latest image from DockerHub.
o The image is run in a container, making the application accessible via the public IP of the
EC2 instance.
Jenkins is configured to send email or Slack notifications in case of build failure or success.
Build logs are retained for debugging purposes.
5. Docker Configuration
Docker Compose
pipeline {
agent any
stages{
stage('cloning code'){
steps{
steps{
stage('push'){
steps{
echo"pushing the code to the docker hub"
stage('deploy'){
steps{
Jenkins connects to the EC2 instance using SSH to deploy the Docker container.
8. Challenges Faced
Managing Environment Variables: Sensitive information like database credentials and
API keys were securely managed using Jenkins credentials.
Automating Tests: Some initial challenges were faced in running the tests inside
Docker, which were resolved by adjusting the Dockerfile.
9. Conclusion
The CI/CD pipeline created for the Django Notes application successfully automated the process
of building, testing, and deploying the application. This pipeline ensures fast delivery, maintains
consistent application versions, and provides a reliable mechanism to scale and update the
application on AWS.