-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c59a1b
commit d73f979
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
version: 2 | ||
defaults: &defaults | ||
docker: | ||
- image: circleci/python:2.7-stretch-browsers | ||
install_dependency: &install_dependency | ||
name: Installation of build and deployment dependencies. | ||
command: | | ||
sudo apt install jq | ||
sudo pip install awscli --upgrade | ||
sudo pip install docker-compose | ||
install_deploysuite: &install_deploysuite | ||
name: Installation of install_deploysuite. | ||
command: | | ||
git clone --branch v1.4.2 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: "member-api" | ||
steps: *builddeploy_steps | ||
|
||
"build-prod": | ||
<<: *defaults | ||
environment: | ||
DEPLOY_ENV: "PROD" | ||
LOGICAL_ENV: "prod" | ||
APPNAME: "member-api" | ||
steps: *builddeploy_steps | ||
|
||
workflows: | ||
version: 2 | ||
build: | ||
jobs: | ||
# Development builds are executed on "develop" branch only. | ||
- "build-dev": | ||
context : org-global | ||
filters: | ||
branches: | ||
only: | ||
- develop | ||
|
||
# Production builds are exectuted only on tagged commits to the | ||
# master branch. | ||
- "build-prod": | ||
context : org-global | ||
filters: | ||
branches: | ||
only: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
APP_NAME=$1 | ||
UPDATE_CACHE="" | ||
#docker-compose -f docker/docker-compose.yml build $APP_NAME | ||
docker build -f docker/Dockerfile -t $APP_NAME:latest . | ||
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 |