Project 1: Notes App
Prerequisites β
EC2 instance π₯οΈ
GitHub π
Docker π³
Docker Hub π
Jenkins π
Steps Included:
π οΈ Configuration Steps:
Create EC2 Instance:
- Set up a new EC2 instance on AWS.π₯οΈ
SSH Connection:
- Connect to your EC2 instance using SSH.π
Update Instance:
- Ensure your instance is up to date with the latest updates.π
Docker Installation:
- Install Docker on your EC2 instance.π³
User Addition to Docker Group:
- Add your user to the Docker group for seamless Docker access.π₯
Java Installation:
- Install Java on your EC2 instance.β
Jenkins Installation:
- Install Jenkins on your EC2 instance.π
Jenkins User to Docker Group:
- Grant Jenkins user access to the Docker group.π©βπ»π³
Reboot Instance:
- Reboot your EC2 instance for changes to take effect.β»οΈ
Inbound Rules Configuration:
- Edit inbound rules to allow access to Jenkins on port 8080.πͺ
Jenkins Setup:
- Finally, configure and set up Jenkins for your continuous integration needs.π οΈ
πPipeline Creation Steps:
New Pipeline Setup:
- Initiate the creation of a new pipeline.
GitHub Project Selection:
- Opt for the 'GitHub Project' option and input the GitHub URL for your project.π
Pipeline Script Configuration:
- Choose 'Pipeline Script' as the script option.π
Groovy Scripting:
Use Groovy script to:
Clone the code from the specified GitHub repository.
Build a Docker image from the cloned code.
Docker Hub Account Creation:
- Create an account on Docker Hub.π
Credentials Setup:
In Jenkins, navigate to 'Manage Jenkins' -> 'Credentials' -> 'System' -> 'Global Credentials' -> 'Add'.
Add Docker Hub credentials using environment variables.π
Dockerhub Credentials in Code:
- Use the 'withCredentials' Groovy syntax to provide Docker Hub login credentials within the pipeline code.π
Image Retagging:
- Retag the previously built image using the 'docker tag' command.π·οΈ
Dockerhub Login:
- Incorporate the script to log in to Docker Hub using the specified credentials.π
Image Push to Dockerhub:
- Push the latest image to Docker Hub using the 'docker push' command.π’
These steps collectively configure a comprehensive pipeline, from code cloning to Docker image pushing, including Docker Hub integration. ππ³
π’ Docker-Compose Deployment and Automated Build Configuration:
Docker-Compose Integration:
- Enhance pipeline robustness by deploying through Docker-Compose. Install Docker-Compose on the instance.π³
Security Configuration:
- Edit inbound rules in security, adding port 8000 for improved access. Verify the application in the browser.πͺ
GitHub Repository Integration:
- Optimize code retrieval by adding a Jenkinsfile to the GitHub repository, containing pipeline code.π
Pipeline Configuration:
Choose the 'Pipeline from SCM' option in Jenkins.
Provide the GitHub repository URL, specify the branch, and mention the Jenkinsfile path. Save the configuration.π
Automated Declarative Checkout:
- Trigger builds with Declarative Checkout SCM by simply clicking 'Build.' The Jenkinsfile in the repository automates the process of code retrieval.π€
Webhook Setup in GitHub:
In GitHub repository settings, add a webhook for automation.
In Jenkins, go to 'Configure' -> 'Build Triggers' -> select 'GitHub hook trigger for GitSCM polling' -> Save.π οΈ
Automated Build Trigger:
- Any changes committed to the GitHub code trigger automatic builds in Jenkins, creating an efficient and automated build pipeline.π
These steps optimize the deployment process through Docker-Compose, enhance security, and automate the build process with GitHub integration, ensuring a seamless and efficient pipeline. ππ
"π Thank you for taking the time to explore this blog!π I hope you found the information both helpful and insightful.β¨
π Enjoy your learning journey, and don't hesitate to reach out if you have any feedback. π€ Happy exploring!"