Skip to content

Commit

Permalink
Finished 'Getting Started' of README
Browse files Browse the repository at this point in the history
  • Loading branch information
MatveyGuralskiy authored May 8, 2024
1 parent 031b52d commit 9095030
Showing 1 changed file with 175 additions and 9 deletions.
184 changes: 175 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,197 @@ After that, we check to make sure everything still works with those Docker image
## 🚀 Getting Started

### 👣 Steps
- [ ] 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 Bootstapping 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
- [x] 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
- [x] 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 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
- [x] Go to Jenkins Dashboard and create Job with Pipeline and use GitHub Plugin
- [x] Create Repository of your Project in GitHub and connect Jenkins with WebHook
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
- [x] 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
- [x] 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
- [x] 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
- [x] 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
- [x] 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
- [x] 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
- [x] 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 Create Record in Route53


#### Create Bash script for Bootstapping for Instances to install docker and pull Image from DockerHub
- [x] Create Bash script for Bootstapping 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
- [x] 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

#### Make changes in GitHub repository to see Auto-Deploy of Project
- [x] 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

#### Create Master Instance
- [x] Create Master-Instance in AWS

Create Security group with ports: 80, 8080, 22, 7000
Now Your Intances will upload new version of Application

Go to AWS EC2 Instances and run Ubuntu Image with Instance type "t3.small"
<h2>🎬 View Demo</h2>
<p>Comming soon...</p>

Create Key-pair in AWS and copy the Private Key for SSH connection

Connect with Protocol SSH to Instance (for example use MobaXterm)
<h2>📂 Repository</h2>
<p>
|-- /Application

|-- /Bash

|-- /Jenkins

|-- /Screens

|-- /terraform

|-- LICENSE

|-- README.md

</p>


- [x] Install Jenkins, Docker, Terraform and nginx on Instance

## 📚 Acknowledgments
Documentations for you to make the project
Expand Down

0 comments on commit 9095030

Please sign in to comment.