From 5d0ec477e512bca2bf953affd34e854b08221079 Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Fri, 29 Jan 2021 17:04:22 +0530 Subject: [PATCH 1/4] circleci integration --- .circleci/config.yml | 81 ++++++++++++++++++++++++++++++++++++++++++++ build.sh | 22 ++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 .circleci/config.yml create mode 100755 build.sh diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..b25d3ab --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,81 @@ +version: 2 +defaults: &defaults + docker: + - image: circleci/node:15.5.1-stretch-browsers +install_dependency: &install_dependency + name: Installation of build and deployment dependencies. + command: | + sudo apt-get update + sudo apt install jq python3-pip + sudo pip3 install awscli --upgrade + sudo pip3 install docker-compose +install_deploysuite: &install_deploysuite + name: Installation of install_deploysuite. + command: | + git clone --branch v1.4.3 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript + cp ./../buildscript/master_deploy.sh . + cp ./../buildscript/buildenv.sh . + cp ./../buildscript/awsconfiguration.sh . +restore_cache_settings_for_build: &restore_cache_settings_for_build + key: docker-node-modules-{{ checksum "package-lock.json" }} + +save_cache_settings: &save_cache_settings + key: docker-node-modules-{{ checksum "package-lock.json" }} + paths: + - node_modules + +builddeploy_steps: &builddeploy_steps + - checkout + - setup_remote_docker + - run: *install_dependency + - run: *install_deploysuite + - restore_cache: *restore_cache_settings_for_build + - run: ./build.sh ${APPNAME} + - save_cache: *save_cache_settings + - deploy: + name: Running MasterScript. + command: | + ./awsconfiguration.sh $DEPLOY_ENV + source awsenvconf +# ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar +# source buildenvvar +# ./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME} + + +jobs: + # Build & Deploy against development backend + "build-dev": + <<: *defaults + environment: + DEPLOY_ENV: "DEV" + LOGICAL_ENV: "dev" + APPNAME: "autopilot-processor" + steps: *builddeploy_steps + + "build-prod": + <<: *defaults + environment: + DEPLOY_ENV: "PROD" + LOGICAL_ENV: "prod" + APPNAME: "autopilot-processor" + steps: *builddeploy_steps + +workflows: + version: 2 + build: + jobs: + # Development builds are executed on "develop" branch only. + - "build-dev": + context : org-global + filters: + branches: + only: + - dev + + # Production builds are exectuted only on tagged commits to the + # master branch. + - "build-prod": + context : org-global + filters: + branches: + only: master \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..aa24a4b --- /dev/null +++ b/build.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -eo pipefail +APP_NAME=$1 +UPDATE_CACHE="" +docker-compose -f docker/docker-compose.yml build $APP_NAME +docker create --name app $APP_NAME:latest + +if [ -d node_modules ] +then + mv package-lock.json old-package-lock.json + docker cp app:/$APP_NAME/package-lock.json package-lock.json + set +eo pipefail + UPDATE_CACHE=$(cmp package-lock.json old-package-lock.json) + set -eo pipefail +else + UPDATE_CACHE=1 +fi + +if [ "$UPDATE_CACHE" == 1 ] +then + docker cp app:/$APP_NAME/node_modules . +fi \ No newline at end of file From cbf769802845acb082433bd3774d54e2f46f9d98 Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Fri, 29 Jan 2021 17:26:11 +0530 Subject: [PATCH 2/4] circleci integration --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b25d3ab..49ca56b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,9 +37,9 @@ builddeploy_steps: &builddeploy_steps command: | ./awsconfiguration.sh $DEPLOY_ENV source awsenvconf -# ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar -# source buildenvvar -# ./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME} + ./buildenv.sh -e $DEPLOY_ENV -b ${LOGICAL_ENV}-${APPNAME}-deployvar + source buildenvvar + ./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${LOGICAL_ENV}-global-appvar,${LOGICAL_ENV}-${APPNAME}-appvar -i ${APPNAME} jobs: From cee97d0328f4f52ab1a88a1570995f01d34427a8 Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Fri, 29 Jan 2021 17:34:16 +0530 Subject: [PATCH 3/4] circleci integration --- .circleci/config.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 49ca56b..ceb2883 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -70,7 +70,8 @@ workflows: filters: branches: only: - - dev + - develop + - dev-circleci # Production builds are exectuted only on tagged commits to the # master branch. From f77fd368d8af221532456f8a92a5ccd3c6b8e0d5 Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Fri, 29 Jan 2021 17:38:25 +0530 Subject: [PATCH 4/4] circleci integration --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index aa24a4b..b2362f3 100755 --- a/build.sh +++ b/build.sh @@ -2,6 +2,7 @@ set -eo pipefail APP_NAME=$1 UPDATE_CACHE="" +echo "" > docker/api.env docker-compose -f docker/docker-compose.yml build $APP_NAME docker create --name app $APP_NAME:latest