Automated Application deployment system using tools such as Docker, Jenkins, Terraform, AWS, Git, GitHub
LinkedIn
.
Report Bug
·
My Website
My project is all about making things easier for developers. Whenever there's a new update on GitHub, a program called Jenkins gets to work. It runs tests to make sure everything's still working smoothly. Then, it takes those files and turns them into special packages called Docker images. These images are stored online on something called Docker Hub.
After that, we check to make sure everything still works with those Docker images. Next up, we use a tool called Terraform to set up all the necessary computer stuff on Amazon Web Services (AWS). Finally, we end up with a fully functional website that you can access using a simple web address. It's all secure, too, with encryption and all that, and it's spread across four servers, each running those Docker packages we made earlier.
- HTML
- CSS
- Create Master-Instance in AWS
- Install Jenkins, Docker, Terraform and nginx on Instance
- Go to Jenkins Dashboard and create Job with Pipeline and use GitHub Plugin
- Create Repository of your Project in GitHub and connect Jenkins with WebHook
- Create Jenkinsfile in Repository
- Add Credentials in Jenkins of AWS, DockerHub, GitHub
- Write Dockerfile
- Copy to Jenkinsfile my pipeline
- Create Empty Repository in DockerHub
- Create in service Certificate Manager SSL Certificate and make DNS Validation with Route53
- Create Bash script for Bootstrapping for Instances to install docker and pull Image from DockerHub
- Run Jenkins Job
- Make changes in GitHub repository to see Auto-Deploy of Project
- Create Master-Instance in AWS
Create Security group with ports: 80, 8080, 22, 7000
Go to AWS EC2 Instances and run Ubuntu Image with Instance type "t3.small"
Create Key-pair in AWS and copy the Private Key for SSH connection
Go to EC2 Instance Console and copy PublicIP
Connect with Protocol SSH to Instance (for example use MobaXterm)
- Install Jenkins, Docker, Terraform and nginx on Instance
Install nginx for Testing
sudo apt update
sudo apt install nginx
Install Jenkins + Java
# Install Java
sudo apt update
sudo apt install fontconfig openjdk-17-jre
#Install Jenkins
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \
https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
/etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins
# To check if Jenkins works
java --version
jenkins --version
Install Docker
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
# Install Docker
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# To Add User to Docker
sudo usermod -aG docker $USER
# To Add Jenkins User to Docker
sudo usermod -aG docker jenkins
# After that Reboot your Instance
# To check if Docker works
docker images
Install Terraform
sudo snap install terraform --classic
terraform --version
- Go to Jenkins Dashboard and create Job with Pipeline and use GitHub Plugin Go to AWS EC2 Instance Console to the PublicIP and copy him
Open Browser and put the PublicIP:8080 and start to sign up and install Plugins
Create Job with Pipeline and choose GitHub and Copy repository link and path to Jenkins
- Create Repository of your Project in GitHub and connect Jenkins with WebHook In GitHub Repository go to Setting --> Webhook and enter the http://PublicIP:8080/github-webhook/
Now every commit you push in GitHub automatically will run Jenkins Job
- Create Jenkinsfile in Repository In GitHub repository create Jenkinsfile or Jenkinsfile.groovy and don't forget in Jenkins Job enter the path to the file
- Add Credentials in Jenkins of AWS, DockerHub, GitHub
Go to Dashboard --> Manage --> Credentials --> Global --> Add credentials
Add credentials for DockerHub and GitHub just email + password
Now for AWS I created IAM profile and download for him Access key and Secret key
So to use them for authorization I used in Credentials type of Secret text and create one for Access Key and the second one for Secret Key
- Write Dockerfile To package your Application to Docker Image you need Dockerfile inside Application directory
You can use my Dockerfile from repository,
He use Amazon Linux Distribution, he makes updates and install Apache Webserver
and at the end he just copy all files from directory and package them to Docker Image, He also uses port 80 to made Webserver
- Copy to Jenkinsfile my pipeline Go to my repository directory Jenkins and use my Jenkinsfile, of course modified it for personal use
- Create Empty Repository in DockerHub Go to DockerHub and Create simple Repository to upload Images of Application from Jenkins
- Create in service Certificate Manager SSL Certificate and make DNS Validation with Route53 Before to work with project you need DNS Domain for usage
Go to AWS Console Certificate Manager and make Request and enter DNS name
Click to Certificate and Click at the button "Create Record in Route53"
In terraform file variables.tf change the arn to arn of Certificate you get
- Create Bash script for Bootstrapping for Instances to install docker and pull Image from DockerHub You can use my Script from repository go to directory Bash --> bootstrapping.sh
Now our Ubuntu Instances will Install Docker and our Docker Image from DockerHub and run it on port 80
- Run Jenkins Job After everything you get all files, Run the Job in Jenkins and enjoy your Application full Deployment:)
Now go to your DNS name for example: "website.matveyguralskiy.com" and you can see your Application in Port 443
with SSL Certificate and if you go to Port 80 Application Load Balancer of AWS will make Redirect to Port 443
Your DockerHub will be look like that
- Make changes in GitHub repository to see Auto-Deploy of Project For example change the Docker version in Jenkinsfile and change HTML file of Application
Now Your Intances will upload new version of Application
To change the Version of Application, You should change Application files in HTML Version,
Bash Bootstrapping to the new version and in Jenkins file environment variable DOCKER VERSION value
And DockerHub get now new versions of Project
It's all Jobs in Jenkins
In AWS Console Route53 get new Record because of Terraform
It's All List of Instances
|-- /Application
|-- /Bash
|-- /Jenkins
|-- /Screens
|-- /terraform
|-- LICENSE
|-- README.md
Documentations for you to make the project
- Jenkins Pipeline
- AWS for begginers
- Terraform work with AWS
- Docker Build Images
- DockerHub Registry
- Git Control your code
- HTML to build Application
- CSS to style Application
- SSH connect to Instances
I hope you liked my project, don’t forget to rate it and if you notice a code malfunction or any other errors.
Don’t hesitate to correct them and be able to improve your project for others
Email - Contact
GitHub - Profile
LinkedIn - Profile
Instagram - Profile
Distributed under the MIT license. See LICENSE.txt for more information.