Skip to content
This repository was archived by the owner on Dec 10, 2019. It is now read-only.
Open
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
Binary file removed .DS_Store
Binary file not shown.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
node_modules
dist
npm-debug.log
src/config/config.json
config/config.json
.idea/
.DS_Store
.terraform
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
sudo: required
language: node_js
node_js: 11.10.0
services:
- docker
addons:
chrome: stable
before_install:
#- export DISPLAY=:99.0
#- sh -e /etc/init.d/xvfb start
- git checkout $TRAVIS_BRANCH
- sudo apt-get update
- sudo apt-get install -y python3-pip
- pip3 install --user awscli
- export PATH=$PATH:$HOME/.local/bin
- eval "$(aws ecr get-login --no-include-email --region us-east-2)"
- docker build -t $ECR_URL .
- docker push $ECR_URL
- aws codebuild start-build --region $AWS_REGION --project-name github-pr-dashboard-deploy
skip_cleanup: true
on:
branch: master

env:
global:
- AWS_REGION=us-east-2
- ECR_URL=859455775147.dkr.ecr.us-east-2.amazonaws.com/express/github-pr-dashboard
- secure: P62vUnAHNJHuyW0ikVSgsH1HvxgqUsiMINSq7ThQo7wm/vnDfFMJKT+yJj7BtXBt3FUxg7Iv2+IkrIaTUD6n/d17JBI5E4rWfFJ2u0/Phshx1aAVItknpNR69PZJh32WB6Xtb4cpMJryUuKTn6QjVXbvtFbeZciWBFGRDMZnPGHJl+uRv4eE98AO1g+/V9HDzDoCVIOlOPHqHeOpKis2fPuOP+rT4IgExeiJjgffAC6tExS8jfqC/10X/00L7dDzgjHR67op81eS7FQYBOaGu5t/QtTs5H6IvcpETS8L6R74XRfVkvxUeLLTojP5dAaDbhxlYVghb2Q7K1V5sC/TVxLSOkaEU82h8jNQxsQRkx3SDys5U3ePfVPM1FhyR3jel71KQhO10js6207EGXE0iOsGKTC0M6TUSbKp61Mf74scV+g4nOcIFa5klKwFZydbf6AQTvixOGHX6QL+d4yPJbA88+Rlz0MAR/IEHUvlyG+dZVKq17FUcI2ib4YCF2uKczm/zhEHYVQ2Y/PaXMKP7QqRebVZp/YDvdKIwYxyppy4fp44iplirzb4a9oXYEd8uc35wwFhhYW9x3Qrja4mGHLowj+L7iLqBxBL4MhVCSp4yjR/ew2kxbHgsC1dFKgRtodTwFjc3h+DLqDNJy4z1D0QHiY32QTtd5uJkLodtIA=
- secure: NZoZBHYZzFN5G8E2mnBfD1noUmEKh9f6COS7ZNmHT3ADyKynmoPIlYGfi/3UtXggsKS7x81NdYMcpq93dujBMQhd9P4u2bwWUigUQ4qmprA+Q0tpqyNCH4BuoWb3tzVNX2qh90SuO4CMwYtRnsQs99dVLGZdhf7Uhj/lCSnlZrPGuEIVDk53bZ87ynkhqvav+Piqu/w1MYDGzArIvQw1QC+gKV6BVsAh1l1fPyDajqIehemJbF2MA83gyKWxKmG+RvOe604cszbMbUoVKah6HthwpP4uL4pEbol+1q5/vhrnyyINxyuQl2gBN35owr0YAw/kMSeHxOzJQvr4FBysmmdbB6Gb50LN7iGxiHXyjg6ou2+dv4o/o9FLJRRkizr2dMv99R5awKUEf3Ubz8wjuQj9KQHpYrVeRJKNofZlDhIcIIXwkgZcxnYzeo4vKNZPFIUkYrj9pqrt5yUNo+bkKH8z8y0GWxEkzRRwoGxmSx6V+EtZ53Mly0xxKU59lrRb0l5tTIENSVB/zvw7xo+RkYRFCFLg5zaLl0HiwVEBIeAcu39ADMHoT4WDV61rzTKCmBgKFG4HBbtw67/r30PdbtxzUiqiVHCzK4+TnCRwcO140nVZDbtnY2jZ3ixHGo4cqjQjxdNhL/HdSsopblXMEqrJiu/F3YE77kYvEHuo4tk=
File renamed without changes.
12 changes: 12 additions & 0 deletions devops/deploy/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#Set up a terraform state file for here on the s3 backend
#DO NOT CHANGE THE REGION HERE! IT'S THE SAME FOR ALL PROJECTS!
#Figure out a better key
terraform {
backend "s3" {
encrypt = true
bucket = "express-terraform-states"
dynamodb_table = "terraform-locks"
region = "us-east-2"
key = "us-east-2/code-build-github-dashboard/terraform.tfstate"
}
}
22 changes: 22 additions & 0 deletions devops/deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: "2"
services:
github-dashboard-lb:
ports:
- 8080
image: rancher/lb-service-haproxy:v0.9.1
github-dashboard:
container_name: 'github-dashboard'
image: 859455775147.dkr.ecr.us-east-2.amazonaws.com/express/github-pr-dashboard
restart: 'always'
stdin_open: true
tty: true
logging:
driver: awslogs
options:
awslogs-region: "us-east-2"
awslogs-group: "/rancher/github-dashboard"
secrets:
- github_pr_config
secrets:
github_pr_config:
external: true
14 changes: 14 additions & 0 deletions devops/deploy/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
data "rancher_environment" "github-pr-dashboard" {
name = "${var.rancher_environment}"
}

resource "rancher_stack" "github-pr-dashboard" {
name = "github-pr-dashboard"
description = "github-pr-dashboard"
environment_id = "${data.rancher_environment.github-pr-dashboard.id}"
docker_compose = "${file("docker-compose.yml")}"
rancher_compose = "${file("rancher-compose.yml")}"
start_on_create = true
finish_upgrade = true

}
7 changes: 7 additions & 0 deletions devops/deploy/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#------------------------------------------#
# AWS Provider Configuration
#------------------------------------------#
provider "aws" {
region = "us-east-2"
# region = "${var.region}"
}
18 changes: 18 additions & 0 deletions devops/deploy/rancher-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

version: '2'
services:
github-dashboard-lb:
scale: 1
lb_config:
port_rules:
- source_port: 8080
target_port: 8080
service: github-dashboard
health_check:
port: 42
interval: 2000
unhealthy_threshold: 3
healthy_threshold: 2
response_timeout: 2000
github-dashboard:
scale: 1
3 changes: 3 additions & 0 deletions devops/deploy/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "rancher_environment" {
default = "Development"
}
9 changes: 9 additions & 0 deletions devops/provisioning/backend.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
backend "s3" {
encrypt = true
bucket = "express-terraform-states"
dynamodb_table = "terraform-locks"
region = "us-east-2"
key = "us-east-2/devops/provisioning/terraform.tfstate"
}
}
25 changes: 25 additions & 0 deletions devops/provisioning/buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 0.2
phases:
install:
commands:
- echo Entered the install phase...
- apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0x219BD9C9
- echo "deb http://repos.azulsystems.com/ubuntu stable main" >> /etc/apt/sources.list.d/zulu.list
- apt-get install -y wget unzip
- wget https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_linux_amd64.zip
- unzip terraform_0.*.zip
- mv terraform /usr/local/bin
build:
commands:
- echo Entered the build phase...
- echo Build started on `date`
- ls -la
- cd devops/deploy
- terraform init
- terraform apply -auto-approve
post_build:
commands:
- if $CODEBUILD_BUILD_SUCCEEDING -eq "0"; then exit 1; fi
- echo Entered the post_build phase..
- export PATCH_VERSION=$(($PATCH_VERSION+1))

84 changes: 84 additions & 0 deletions devops/provisioning/code-build.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
data "template_file" "app_build" {
template = "${file("${path.module}/buildspec.yml")}"
}

resource "aws_codebuild_project" "app_buildjob" {
name = "${var.app_name}-deploy"
description = "${var.app_name} Code build job"
build_timeout = "15"
badge_enabled = true
service_role = "${data.aws_iam_role.code_build_role.arn}"

artifacts {
type = "NO_ARTIFACTS"
}

cache {
type = "S3"
location = "${data.aws_s3_bucket.tf_codebuild_bucket.bucket}"
}

source {
type = "GITHUB"
location = "${var.app_repo_link}"
git_clone_depth = 1
buildspec = "${data.template_file.app_build.rendered}"
}

environment {
compute_type = "BUILD_GENERAL1_SMALL"
image = "aws/codebuild/java:openjdk-8-1.6.0"
type = "LINUX_CONTAINER"
privileged_mode = true

environment_variable {
"name" = "PATCH_VERSION"
"value" = "1"
}

environment_variable {
"name" = "TF_VAR_PATCH_VERSION"
"value" = "1"
}

environment_variable {
"name" = "AWS_DEFAULT_REGION"
"value" = "us-east-2"
}

environment_variable {
"name" = "AWS_ACCESS_KEY_ID"
"value" = "/CodeBuild/buildAccessKey"
"type" = "PARAMETER_STORE"
}

environment_variable {
"name" = "AWS_SECRET_ACCESS_KEY"
"value" = "/CodeBuild/buildAccessSecret"
"type" = "PARAMETER_STORE"
}

environment_variable {
"name" = "RANCHER_URL"
"value" = "https://ras.mgmt.cloud.express.com/v2-beta/projects/1a6448"
}

environment_variable {
"name" = "RANCHER_ACCESS_KEY"
"value" = "/CodeBuild/CodeBuild/ctDevRancherApiKey-nt"
"type" = "PARAMETER_STORE"
}

environment_variable {
"name" = "RANCHER_SECRET_KEY"
"value" = "/CodeBuild/CodeBuild/ctDevRancherApiSecret-nt"
"type" = "PARAMETER_STORE"
}
}

tags {
Name = "${var.app_environment}_${var.app_name}_codebuild"
env = "${var.app_environment}"
system = "${var.app_name}"
}
}
6 changes: 6 additions & 0 deletions devops/provisioning/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#------------------------------------------#
# AWS Provider Configuration
#------------------------------------------#
provider "aws" {
region = "${var.region}"
}
29 changes: 29 additions & 0 deletions devops/provisioning/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "region" {
default = "us-east-2"
}

variable "app_name" {
default = "gitthub-pr-dashboard"
}

variable "app_environment" {
default = "dev"
}

variable "app_repository" {
default = "github-pr-dashboard"
}

variable "app_repo_link" {
default = "https://github.com/express-labs/github-pr-dashboard.git"
}

############################################
#### Resource 2: AWS Data filters
data "aws_iam_role" "code_build_role" {
name = "${var.app_environment}-codebuild-iam"
}

data "aws_s3_bucket" "tf_codebuild_bucket" {
bucket = "${var.app_environment}-tfcodebuild-bucket"
}
Loading