Skip to content
Closed

Dev #12

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pipeline {
sshagent(['ec2-ssh-key']){
sh """
ssh -tt -o StrictHostKeyChecking=no ubuntu@${targetHost} << EOF
sudo apt install -y awscli
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${env.ECR_REPO}
docker pull ${ECR_REPO}:${TAG}
docker stop ${IMAGE_NAME} || true
Expand Down
43 changes: 38 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,45 @@

4. **Define Jenkinsfile with Email Notification Step**
- In the Jenkinsfile replace the Environment variables with yours.
- Configure correct login details in Manage Jenkins -> Credentials
- Configure correct login details in Manage Jenkins -> Credentials -> add the following credentials
- Sonarqube token ('sonartoken')
- Github-Token
- AWS CLI Access key and Secret access key ('aws-ecr')
- Private SSH key pair for EC2 instance ('ec2-ssh-key')
- Gmail Username and App password ('gmailcreds')
- Add the following in Manage Jenkins -> System
- Sonarqube server details -> pass the authentication details -> (Name: 'SonarQubeServer', Auth token: 'sonartoken')
- E-mail Notification -> pass the authentication details -> ('gmailcreds')
- Install trivy on worker machines
```bash
- wget https://github.com/aquasecurity/trivy/releases/download/v0.57.0/trivy_0.57.0_Linux-64bit.deb
- sudo dpkg -i trivy_0.57.0_Linux-64bit.deb
- trivy --version
- trivy --timeout 10m image imagename
wget https://github.com/aquasecurity/trivy/releases/download/v0.57.0/trivy_0.57.0_Linux-64bit.deb
sudo dpkg -i trivy_0.57.0_Linux-64bit.deb
trivy --version
trivy --timeout 10m image imagename
```
- The timeout will make sure trivy command gets enough time to download the dependencies
- Create 3 EC2 instances for different environments and pass their IP addresses in stage('Deploy to Environment')
- Install awscli on these instances because we will use awscli command to talk to AWS ECR to get a temporary token
```bash
# aws ecr gets a temporary token from aws in eu-west-2 which will be used by docker without rquiring permanent creds
# docker login --username AWS --password-stdin //temporary token ${ECRREPO}
aws ecr get-login-password --region eu-west-2 | docker login --username AWS --password-stdin ${env.ECR_REPO}
docker pull ${ECR_REPO}:${TAG}
docker stop ${IMAGE_NAME} || true
docker rm ${IMAGE_NAME} || true
docker run -d --name ${IMAGE_NAME} -p 8080:8080 -p 8090:8090 ${ECR_REPO}:${TAG}
```

## STEPS INVOLVED

1. **STAGE 1: Verify git on Agent machine**
2. **STAGE 2: Pull the source code from GitHub Repository.**
3. **STAGE 3: Build docker image based on the Dockerfile Configuration.**
1. The Dockerfile uses nginx as base image
2. Removes default nginx configuration and replaces with our custom configuration
3. Copies application code from directories app1 and app2 and places them on nginx/html/
4. Builds docker image exposing 2 ports 8080 and 8090
4. **STAGE 4: To push the docker image that was build in the previous step to amazon ECR and send an email notification.**
5. **STAGE 5: Sonarqube server scans the project code for any vulnerabilities if test passes according to QUALITY GATE criteria on Sonarqube pipeline moves to next stage.**
6. **STAGE 6: We do a trivy scan on the AMAZON ECR image and send a report in email.**
7. **STAGE 7: Deploy the AWS ECR image on different EC2 instances according to the Environment and from which branch the code was updated.**
9 changes: 9 additions & 0 deletions app1/ABOUT THIS TEMPLATE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Tooplate.com HTML Templates

You can feel free to edit and use this template for any purpose (personal or business or commercial) of your website. You can modify text and images to suit your own website or client websites.

You are NOT allowed to re-distribute our template file for any reason on your template sites or template collection sites.

You can put a screenshot and a link back to our template page. That is helpful for us.

THANK YOU
20 changes: 20 additions & 0 deletions app1/LICENSE-fullcalendar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2015 Adam Shaw

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
196 changes: 196 additions & 0 deletions app1/accounts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Accounts Page - Dashboard Template</title>
<!--

Template 2108 Dashboard

http://www.tooplate.com/view/2108-dashboard

-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600">
<!-- https://fonts.google.com/specimen/Open+Sans -->
<link rel="stylesheet" href="css/fontawesome.min.css">
<!-- https://fontawesome.com/ -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- https://getbootstrap.com/ -->
<link rel="stylesheet" href="css/tooplate.css">
</head>

<body class="bg03">
<div class="container">
<div class="row">
<div class="col-12">
<nav class="navbar navbar-expand-xl navbar-light bg-light">
<a class="navbar-brand" href="index.html">
<i class="fas fa-3x fa-tachometer-alt tm-site-icon"></i>
<h1 class="tm-site-title mb-0">Dashboard</h1>
</a>
<button class="navbar-toggler ml-auto mr-0" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mx-auto">
<li class="nav-item">
<a class="nav-link" href="index.html">Dashboard
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="index.html" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
Reports
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Daily Report</a>
<a class="dropdown-item" href="#">Weekly Report</a>
<a class="dropdown-item" href="index.html">Yearly Report</a>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="products.html">Products</a>
</li>

<li class="nav-item active">
<a class="nav-link" href="#">Accounts</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false">
Settings
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Profile</a>
<a class="dropdown-item" href="#">Billing</a>
<a class="dropdown-item" href="#">Customize</a>
</div>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link d-flex" href="login.html">
<i class="far fa-user mr-2 tm-logout-icon"></i>
<span>Logout</span>
</a>
</li>
</ul>
</div>
</nav>
</div>
</div>
<!-- row -->
<div class="row tm-content-row tm-mt-big">
<div class="tm-col tm-col-big">
<div class="bg-white tm-block">
<div class="row">
<div class="col-12">
<h2 class="tm-block-title d-inline-block">Accounts</h2>
</div>
</div>
<ol class="tm-list-group tm-list-group-alternate-color tm-list-group-pad-big">
<li class="tm-list-group-item">
Donec eget libero
</li>
<li class="tm-list-group-item">
Nunc luctus suscipit elementum
</li>
<li class="tm-list-group-item">
Maecenas eu justo maximus
</li>
<li class="tm-list-group-item">
Pellentesque auctor urna nunc
</li>
<li class="tm-list-group-item">
Sit amet aliquam lorem efficitur
</li>
<li class="tm-list-group-item">
Pellentesque auctor urna nunc
</li>
<li class="tm-list-group-item">
Sit amet aliquam lorem efficitur
</li>
</ol>
</div>
</div>
<div class="tm-col tm-col-big">
<div class="bg-white tm-block">
<div class="row">
<div class="col-12">
<h2 class="tm-block-title">Edit Account</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<form action="" class="tm-signup-form">
<div class="form-group">
<label for="name">Account Name</label>
<input placeholder="Vulputate Eleifend Nulla" id="name" name="name" type="text" class="form-control validate">
</div>
<div class="form-group">
<label for="email">Account Email</label>
<input placeholder="[email protected]" id="email" name="email" type="email" class="form-control validate">
</div>
<div class="form-group">
<label for="password">Password</label>
<input placeholder="******" id="password" name="password" type="password" class="form-control validate">
</div>
<div class="form-group">
<label for="password2">Re-enter Password</label>
<input placeholder="******" id="password2" name="password2" type="password" class="form-control validate">
</div>
<div class="form-group">
<label for="phone">Phone</label>
<input placeholder="010-030-0440" id="phone" name="phone" type="tel" class="form-control validate">
</div>
<div class="row">
<div class="col-12 col-sm-4">
<button type="submit" class="btn btn-primary">Update
</button>
</div>
<div class="col-12 col-sm-8 tm-btn-right">
<button type="submit" class="btn btn-danger">Delete Account
</button>
</div>
</div>

</form>
</div>
</div>
</div>
</div>
<div class="tm-col tm-col-small">
<div class="bg-white tm-block">
<h2 class="tm-block-title">Profile Image</h2>
<img src="img/profile-image.png" alt="Profile Image" class="img-fluid">
<div class="custom-file mt-3 mb-3">
<input id="fileInput" type="file" style="display:none;" />
<input type="button" class="btn btn-primary d-block mx-xl-auto" value="Upload New..." onclick="document.getElementById('fileInput').click();"
/>
</div>
</div>
</div>
</div>
<footer class="row tm-mt-small">
<div class="col-12 font-weight-light">
<p class="d-inline-block tm-bg-black text-white py-2 px-4">
Copyright &copy; 2018 Admin Dashboard . Created by
<a rel="nofollow" href="https://www.tooplate.com" class="text-white tm-footer-link">Tooplate</a>
</p>
</div>
</footer>
</div>

<script src="js/jquery-3.3.1.min.js"></script>
<!-- https://jquery.com/download/ -->
<script src="js/bootstrap.min.js"></script>
<!-- https://getbootstrap.com/ -->
</body>

</html>
Loading