Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom image for voyager build / AWS deployment #1942

Merged
merged 2 commits into from
Feb 12, 2019
Merged
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
86 changes: 58 additions & 28 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,14 @@ aliases:
- &WORKSPACE /tmp/voyager
- &DIST /tmp/voyager/app/dist
# Pick docker versions here only, then use the aliases in the executors definition
- &docker-node circleci/node:10.15
- &docker-browsers circleci/node:10.15-browsers
- &docker-node tendermintdev/voyager_node
mircea-c marked this conversation as resolved.
Show resolved Hide resolved
- &docker-browsers tendermintdev/voyager_node_browser
- &docker-go circleci/golang:1.11
- &docker-aws cibuilds/aws:1.15
- &docker-deploy tendermintdev/website_deployment

# reusable commands
commands:
yarn-update:
description: "[YARN] fetch new version"
steps:
- run:
name: Update Yarn
# Audit command is available with safety patches only since 1.13.0
command: sudo npm -g uninstall yarn ; sudo npm -g install yarn@1.13.0
yarn-install:
description: "[YARN] update and install"
steps:
Expand All @@ -38,17 +32,52 @@ commands:

sync:
parameters:
from:
type: string
to:
dist_path:
type: string
overwrite:
default: false
type: boolean
steps:
- run:
name: Deploy to S3
command: "aws s3 sync << parameters.from >> << parameters.to >><<# parameters.overwrite >> --delete<</ parameters.overwrite >>"
name: Set default environment variables
command: |
cd && touch $BASH_ENV

if [ "${CIRCLE_BRANCH}" == "master" ]; then
echo 'export INFRA_PATH=iac/conf/websites/prod/${CIRCLE_PROJECT_REPONAME}' >> $BASH_ENV
echo 'export DEPLOYMENT_ENV=${CIRCLE_PROJECT_REPONAME}' >> $BASH_ENV
echo 'export GIT_BRANCH=${CIRCLE_BRANCH}' >> $BASH_ENV
else
echo 'export INFRA_PATH=iac/conf/websites/dev/${CIRCLE_PROJECT_REPONAME}-staging.interblock.io' >> $BASH_ENV
echo 'export DEPLOYMENT_ENV=${CIRCLE_PROJECT_REPONAME}-staging.interblock.io' >> $BASH_ENV
echo 'export GIT_BRANCH=${CIRCLE_BRANCH}' >> $BASH_ENV
fi
- run:
name: Set the terragrunt iam role
command: |
source $BASH_ENV
echo "role_arn = `chamber read $DEPLOYMENT_ENV terragrunt_iam_role -q`" >> /root/.aws/config
- run:
name: Run terraform plan
command: |
source $BASH_ENV
git clone git@github.com:tendermint/devops.git && cd devops
git checkout $GIT_BRANCH
cd $INFRA_PATH
terragrunt plan
terragrunt output -json > ~/project/terraform_output
- run:
name: Sync dist folder to s3 bucket
command: |
export BUCKET_NAME=`cat terraform_output | jq --raw-output '.website_s3_bucket.value'`
cd << parameters.dist_path >>
echo "deployment job ID = $CIRCLE_BUILD_NUM<br>" >> version.html
echo "deployment job URL = $CIRCLE_BUILD_URL<br>" >> version.html
chamber exec $DEPLOYMENT_ENV -- aws s3 sync . s3://$BUCKET_NAME --profile terraform --delete
- run:
name: Invalidate the cloudfront distribution
command: |
export DISTRIBUTION_ID=`cat terraform_output | jq --raw-output '.distribution_id.value'`
chamber exec $DEPLOYMENT_ENV -- aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID \
--profile terraform \
--path "/*"

# a reusable executor
executors:
Expand All @@ -70,12 +99,18 @@ executors:
- image: *docker-go
working_directory: *GAIA

web_deploy:
docker:
- image: *docker-deploy
environment:
BASH_ENV: /root/.bashrc
AWS_REGION: us-east-1

jobs:
build:
executor: web
steps:
- checkout
- yarn-update
- yarn-install
- run: |
mkdir -p app/dist
Expand Down Expand Up @@ -123,15 +158,13 @@ jobs:
executor: node
steps:
- checkout
- yarn-update
- yarn-install
- run: yarn run lint

testUnit:
executor: web
steps:
- checkout
- yarn-update
- yarn-install
- run:
name: Test
Expand All @@ -145,7 +178,6 @@ jobs:
executor: web
steps:
- checkout
- yarn-update
- run:
name: Audit
command: |
Expand All @@ -170,7 +202,6 @@ jobs:
- checkout
- attach_workspace:
at: *GAIA
- yarn-update
- yarn-install
- run:
name: Test
Expand All @@ -181,22 +212,19 @@ jobs:
when: on_fail

deploy2s3:
executor: aws
executor: web_deploy
steps:
- attach_workspace:
at: *WORKSPACE
- sync:
from: *DIST
to: "s3://cosmos-voyager"
overwrite: true
dist_path: *DIST

# Create release.
release:
docker:
- image: *docker-node
steps:
- checkout
- yarn-update
- yarn-install
- run: node tasks/createReleasePR.js

Expand Down Expand Up @@ -277,7 +305,9 @@ workflows:
- build
filters:
branches:
only: develop
only:
- develop
- master

# - testE2e:
# requires:
Expand Down