/howto-devops-aws-jenkins-docker

A step-by-step guide on how to do DevOps CI/CD using AWS, Jenkins and Docker.

Overview

A step-by-step guide on how to do DevOps CI/CD using AWS, Jenkins and Docker.

Create AWS Account

AWS Free Tier Promotion AWS Free Tier Promotion

Create AWS Account Create AWS Account

Select Account Type Select Account Type

Optional - Personalize Experience

This gives AWS an opportunity to provide tutorial suggestions and tailor the user experience to your specific role. Personalize Experience

Login to AWS Console Login to AWS Console

Select CloudFormation Service Select CloudFormation Service

Click Create Stack Click Create Stack

Select Create Template Designer Select Create Template Designer

Click Create Template In Designer Click Create Template In Designer

Select YAML Radio Button Select YAML Radio Button

Select Template Tab Select Template Tab

Clear Template Section Clear Template Section

Copy/Paste EC2 Template Copy/Paste EC2 Template Copy Template From

https://raw.githubusercontent.com/subsari/snippets/master/aws/ec2-centos7-instance.yml

Click Refresh Icon Click Refresh Icon

Click Valid Icon

This will validate the template and prompt you if there are any syntax errors. Click Valid Icon Checkmark

Click Create Stack Icon Click Create Stack Icon

Click Next On Create Stack Click Next On Create Stack

Specify Stack Name Specify Stack Name

Specify PUBLIC SSH Key

HowToGenerateSSHKey.MD

Specify Public SSH Key

Specify Default Security Group, Any Subnet and Default VPC

Specify Stack Options Specify Stack Options

Click Next On Stack Options Click Next On Stack Options

Review Stack Options Review Stack Options

Click Next On Review Stack Options Click Next On Review Stack Options

Stack Creation In Progress Stack Creation In Progress

Stack Creation Done Stack Creation Done

View Stack Resources

Click the Refresh Icon on the right-hand side. Click Stack Resources

Navigate To Stack Resource Click Stack Resource

Copy EC2 Public IP Copy EC2 Public IP

Check Inbound Range IP Check IP Inbound Range

Do you know/recognize the 'Source' value? If not, then follow the link below before continuing.

HowToOpenSecurityGroup.MD

Connect to EC2 Instance Using SSH & Private Key SSH to EC2 Instance Using SSH & Private Key

Install Java, Install & Configure Jenkins

  1. HowToInstallJava
  2. HowToInstallJenkins
  3. HowToConfigureJenkins

Install cURL

sudo yum install curl -y

Install GIT

  1. Connect to Instance
  2. Execute Yum Command
sudo yum install git -y

Install Git

Install Docker

  1. Connect to Instance
  2. Execute Docker Install Command
sudo yum install docker -y

Install Docker

Enable Docker

sudo systemctl enable docker

Start Docker

sudo systemctl start docker

Jenkins

Create New Jenkins Job Create New Jenkins Job

Create New Jenkins Pipeline Create New Jenkins Pipeline

Specify Pipeline Details

  1. Check Prevent Concurrent Builds
  2. Specify To Build Every 5 Minutes Specify Pipeline Details
  3. Copy/Paste Pipeline Script From https://raw.githubusercontent.com/subsari/snippets/master/jenkins/pipeline-example.yml

Specify Pipeline Script

Click 'Build Now' to Build Pipeline Build Pipeline

Wait For Pipeline To Build Wait For Pipeline To Build

Navigate To Build Navigate To Build

View Build Log View Build Log

View Builds Overview View Builds

Setup Continuous Integration & Continuous Deployment

  1. HowToInstallJenkinsGithubPlugin.MD
  2. HowToBuildJenkinsOnGitPush.MD

Final Result Video

Process Overview

  1. Code pushed to repository
  2. Webhook project triggered from code pushed
  3. Webhook project builds
  4. MyProjectPipeline builds (triggered after successful build of Webhook project)

MyProjectPipeline Builds

  1. Repository cloned to workspace
  2. Docker image is built
  3. Docker instance runs
  4. Unit & Integration tests run on Docker instance
  5. Environment is cleaned up (ie. remove Docker instance & workspace)
  6. Code promoted and deployed on successful testing

DevOps Landscape

DevOps CI/CD AWS, Jenkins & Docker