- Introduction
- Pipeline Diagram
- Reverse Proxy and Load Balancer Diagram
- Development Environment
- Jenkins CI/CD Pipeline
- AWS EC2 Deployment
- Installation Guide
- License and Author
This project demonstrates a complete automated deployment pipeline for a Todo application using Docker, Jenkins, and Docker Compose. It utilizes GitHub for version control, Jenkins for CI/CD, and AWS EC2 as the deployment environment.
The following diagram illustrates the complete CI/CD pipeline setup that involves source code management, Jenkins automation, Docker image building, and Watchtower monitoring:
The following diagram illustrates the setup of a reverse proxy and load balancer using Nginx to route traffic to multiple services of the Todo api:
- The source code is hosted in a GitHub repository, containing the application logic, infrastructure configuration, and other essential files.
- Branch protection policies ensure that only tested and reviewed code gets merged into the main branch.
- Linter testing ensures code quality by enforcing coding standards and identifying issues early in the development pipeline.
- A GitHub webhook notifies Jenkins of any new commits, automatically triggering the build and deployment pipeline.
- Jenkins pulls the latest code from the GitHub repository to ensure that it is using the most current version.
- Jenkins builds a Docker image from the source code using the Dockerfile defined in the repository.
- Jenkins logs into Docker Hub and pushes the built Docker image, making it available for deployment.
- Watchtower monitors the Docker Hub repository for any updates to the Docker image, ensuring the deployment is always using the latest version.
- When a new Docker image is detected, Watchtower updates the running containers using a rolling update strategy, minimizing downtime.
You need to have the following software installed on your machine:
- Git
- Docker
- Docker Compose
-
Clone the Repository:
git clone https://github.com/moheladwy/TodoDeployment.git Todo-Deployment
-
Navigate to the Project Directory:
cd Todo-Deployment
-
Make the Script Executable:
chmod +x ./start-all.sh
-
Start the Application: Run the startup script to:
- Launch Watchtower to monitor container updates.
- Start Portainer for Docker environment management.
- Set up Jenkins for CI/CD automation.
./start-all.sh
-
Access Portainer: Open your browser and navigate to
https://localhost:9443
to access Portainer. Create a new user account and log in. -
Access Jenkins: Navigate to
http://localhost:8090
to access Jenkins. Unlock Jenkins by following these steps:- Open the console of the Jenkins container in Portainer.
- Retrieve the secret key:
cat /var/jenkins_home/secrets/initialAdminPassword
- Use the key to unlock Jenkins, install the suggested plugins, and create a new admin user.
-
Set Up Jenkins Pipeline:
- Create a new pipeline and configure it to use the Jenkinsfile from the repository:
https://github.com/moheladwy/TodoFullstack.git
. - Add Docker Hub credentials to Jenkins.
- Update the Jenkinsfile with your Docker Hub repository, save, and run the pipeline. This will build and push the Todo API image to Docker Hub.
- Create a new pipeline and configure it to use the Jenkinsfile from the repository:
-
Update The
todo-compose.yml
File:- Modify the image name in the
todo-compose.yml
file to point to your Docker Hub repository instead ofonly1adwy/todo-api
.
- Modify the image name in the
-
Start the Todo API:
docker-compose -f todo-compose.yml up -d
-
Monitor with Watchtower: Watchtower will automatically update the Todo API container with the latest image once it is pushed to Docker Hub.
-
Access the Todo API: Open your browser and navigate to
http://localhost:8070/swagger/index.html
to access the Todo API.
This project is open source, feel free to use, modify, and distribute the code as needed. If you have any questions or suggestions, please feel free to reach out.
Author: Mohamed Al-Adawy
- GitHub: https://github.com/moheladwy
- Website: https://al-adawy.netlify.app
- LinkedIn: https://www.linkedin.com/in/mohamedhusseineladwy