Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 7a62717

Browse files
authored
Merge pull request #16 from topcoder-platform/dev
added config for actian agreement
2 parents 1bf0c43 + 56e121c commit 7a62717

40 files changed

+1867
-537
lines changed

.circleci/config.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: appiriodevops/openjdk7:buildv1
5+
6+
install_dependency: &install_dependency
7+
name: Installation of build dependencies.
8+
command: |
9+
sed -i '/jessie-updates/d' /etc/apt/sources.list
10+
apt update
11+
apt install -y openssl ant git zip jq
12+
mkdir ~/awscli
13+
cd ~/awscli
14+
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
15+
unzip awscli-bundle.zip
16+
./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
17+
cd /usr/share/ant/lib
18+
wget https://repo1.maven.org/maven2/org/codehaus/groovy/groovy-all/1.7.8/groovy-all-1.7.8.jar
19+
wget https://repo1.maven.org/maven2/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar
20+
cd ~
21+
wget http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-4.2.3.GA/jboss-4.2.3.GA-jdk6.zip
22+
unzip jboss-4.2.3.GA-jdk6.zip
23+
cd project
24+
install_deploysuite: &install_deploysuite
25+
name: Installation of install_deploysuite.
26+
command: |
27+
git clone --branch v1.3 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
28+
cp ./../buildscript/master_deploy.sh .
29+
cp ./../buildscript/buildenv.sh .
30+
cp ./../buildscript/awsconfiguration.sh .
31+
install_dependentrepo: &install_dependentrepo
32+
name: Installation of install_deploysuite.
33+
command: |
34+
git clone --branch $GLUE_BRANCH https://github.com/topcoder-platform/tc-website-glue ../glue
35+
git clone --branch $TCSHARED_BRANCH https://github.com/topcoder-platform/tc-website-shared ../shared
36+
git clone --branch $TCEA_BRANCH https://github.com/topcoder-platform/tc-website-external-artifacts ../external-artifacts
37+
git clone --branch $TCCACHE_BRANCH https://github.com/appirio-tech/tc-cache ../tc-cache
38+
build_steps: &build_steps
39+
# Initialization.
40+
# - run: *install_dependency
41+
- checkout
42+
- run: *install_deploysuite
43+
- run: *install_dependentrepo
44+
- run:
45+
name: "AWS Configuration"
46+
command: |
47+
./awsconfiguration.sh $BUILD_ENV
48+
source awsenvconf
49+
- run:
50+
name: Building application
51+
command: |
52+
source awsenvconf
53+
ant -f move.xml package-topcoder
54+
zip -r lib.zip lib
55+
zip -r resources.zip resources
56+
cd ../tc-cache && ant && cp build/dist/lib/tcs/tc_cache/1.0.0/tc_cache.jar ../project/ && cd ../project
57+
# - store_artifacts:
58+
# path: ./topcoder.jar
59+
# destination: topcoder.jar
60+
# - store_artifacts:
61+
# path: ./tc_cache.jar
62+
# destination: tc_cache.jar
63+
- run:
64+
name: Build Pacakge
65+
command: ./build-package.sh $BUILD_ENV
66+
- run:
67+
name: "Deployment tc-website app"
68+
command: |
69+
source awsenvconf
70+
echo $VER
71+
# cp -f buildvar-app.conf buildvar.conf
72+
./deploy.sh $BUILD_ENV $VER
73+
74+
75+
jobs:
76+
# Build & Deploy against development backend
77+
"build-dev":
78+
<<: *defaults
79+
environment:
80+
BUILD_ENV: "DEV"
81+
GLUE_BRANCH: "dev"
82+
TCSHARED_BRANCH: "dev"
83+
TCEA_BRANCH: "dev"
84+
TCCACHE_BRANCH: "master"
85+
steps: *build_steps
86+
87+
"build-prod":
88+
<<: *defaults
89+
environment:
90+
BUILD_ENV: "PROD"
91+
GLUE_BRANCH: "master"
92+
TCSHARED_BRANCH: "master"
93+
TCEA_BRANCH: "master"
94+
TCCACHE_BRANCH: "master"
95+
steps: *build_steps
96+
97+
workflows:
98+
version: 2
99+
build:
100+
jobs:
101+
- Hold [TC-Website-Build-Deploy]:
102+
type: approval
103+
- build-dev:
104+
context : org-global
105+
requires:
106+
- Hold [TC-Website-Build-Deploy]
107+
filters:
108+
branches:
109+
only: [dev, reskin-payment]
110+
- build-prod:
111+
context : org-global
112+
requires:
113+
- Hold [TC-Website-Build-Deploy]
114+
filters:
115+
branches:
116+
only: master

appspec.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: 0.0
2+
os: linux
3+
files:
4+
- source: ./topcoder.jar
5+
destination: /home/web/web_backup/
6+
# - source: ./tc_cache.jar
7+
# destination: /home/web/web_backup/
8+
# - source: ./lib.zip
9+
# destination: /home/web/web_backup/
10+
# - source: ./resources.zip
11+
# destination: /home/web/web_backup/
12+
permissions:
13+
- object: /home/web/web_backup
14+
pattern: "topcoder.jar"
15+
owner: web
16+
group: apps
17+
# - object: /home/web/web_backup
18+
# pattern: "tc_cache.jar"
19+
# owner: web
20+
# group: apps
21+
# - object: /home/web/web_backup
22+
# pattern: "lib.zip"
23+
# owner: web
24+
# group: apps
25+
# - object: /home/web/web_backup
26+
# pattern: "resources.zip"
27+
# owner: web
28+
# group: apps
29+
hooks:
30+
BeforeInstall:
31+
- location: remote-cmd-backup-app.sh
32+
runas: web
33+
AfterInstall:
34+
- location: remote-cmd-expand-app.sh
35+
runas: web
36+
- location: remote-cmd-stop-server.sh
37+
runas: web
38+
- location: remote-cmd-deploy-app.sh
39+
runas: web
40+
ApplicationStart:
41+
- location: remote-cmd-start-server.sh
42+
runas: web

build-package.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
#Preparing paackage
3+
ENV=$1
4+
if [ -z $ENV ];
5+
then
6+
echo "The script need to be executed with version ex:build-package.sh ENV"
7+
exit 1
8+
fi
9+
10+
VER=`date "+%Y%m%d%H%M"`
11+
SCRIPTDIR="./deployscripts"
12+
13+
BUILD_VARIABLE_FILE_NAME="./buildvar.conf"
14+
source $BUILD_VARIABLE_FILE_NAME
15+
AWS_CD_PACKAGE_NAME="${APPNAME}-${PACKAGETYPE}-${VER}.zip"
16+
PACAKAGE_LOCATION="dist-${PACKAGETYPE}"
17+
rm -rf $PACAKAGE_LOCATION
18+
mkdir $PACAKAGE_LOCATION
19+
cp -rvf $SCRIPTDIR/* $PACAKAGE_LOCATION/
20+
cp lib.zip lib $PACAKAGE_LOCATION/
21+
cp resources.zip $PACAKAGE_LOCATION/
22+
cp topcoder.jar $PACAKAGE_LOCATION/
23+
cp tc_cache.jar $PACAKAGE_LOCATION/
24+
cp appspec.yml $PACAKAGE_LOCATION/appspec.yml
25+
zip -j $AWS_CD_PACKAGE_NAME $PACAKAGE_LOCATION/*
26+
27+
28+
VER1=$VER
29+
echo export VER="$VER1" >> "$BASH_ENV"

buildvar.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
APPNAME="tc-website"
2+
PACKAGETYPE="app"
3+
DEPLOY=1
4+
DEV_AWS_REGION="us-east-1"
5+
DEV_AWS_CD_APPNAME="tc-website-app"
6+
DEV_AWS_CD_DG_NAME="tc-website-app"
7+
DEV_AWS_CD_DG_CONFIGURATION="CodeDeployDefault.AllAtOnce"
8+
DEV_AWS_S3_BUCKET="tc-website-app-dev"
9+
DEV_AWS_S3_KEY_LOCATION=""
10+
PROD_AWS_REGION="us-east-1"
11+
PROD_AWS_CD_APPNAME="tc-website-app"
12+
PROD_AWS_CD_DG_NAME="tc-website-app"
13+
PROD_AWS_CD_DG_CONFIGURATION="CodeDeployDefault.AllAtOnce"
14+
PROD_AWS_S3_BUCKET="tc-website-app-prod"
15+
PROD_AWS_S3_KEY_LOCATION=""

circle.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

conf/loadtcs.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<classname>com.topcoder.utilities.dwload.TCLoadTCS</classname>
77
<parameterList>
88
<parameter name="submission_dir" value="file:/tcssubmissions/"/>
9+
<parameter name="full_load" value="false"/>
10+
<parameter name="batch_size_days" value="15"/>
911
</parameterList>
1012
</load>
11-
</loadDefinition>
13+
</loadDefinition>

deploy.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
3+
ENV=$1
4+
APPVER=$2
5+
6+
if [ -z $APPVER ] || [ -z $ENV ];
7+
then
8+
echo "The script need to be executed with version ex:deploy.sh ENV 123"
9+
exit 1
10+
fi
11+
12+
JQ="jq --raw-output --exit-status"
13+
COUNTER_LIMIT=20
14+
15+
BUILD_VARIABLE_FILE_NAME="./buildvar.conf"
16+
source $BUILD_VARIABLE_FILE_NAME
17+
18+
AWS_CD_APPNAME=$(eval "echo \$${ENV}_AWS_CD_APPNAME")
19+
AWS_CD_DG_NAME=$(eval "echo \$${ENV}_AWS_CD_DG_NAME")
20+
AWS_CD_DG_CONFIGURATION=$(eval "echo \$${ENV}_AWS_CD_DG_CONFIGURATION")
21+
AWS_S3_BUCKET=$(eval "echo \$${ENV}_AWS_S3_BUCKET")
22+
AWS_S3_KEY_LOCATION=$(eval "echo \$${ENV}_AWS_S3_KEY_LOCATION")
23+
24+
AWS_CD_PACKAGE_NAME="${APPNAME}-${PACKAGETYPE}-${APPVER}.zip"
25+
if [ "$AWS_S3_KEY_LOCATION" = "" ] ;
26+
then
27+
AWS_S3_KEY="${AWS_CD_PACKAGE_NAME}"
28+
else
29+
AWS_S3_KEY="$AWS_S3_KEY_LOCATION/${AWS_CD_PACKAGE_NAME}"
30+
fi
31+
DEPLOYID=""
32+
#log Function - Used to provide information of execution information with date and time
33+
log()
34+
{
35+
echo "`date +'%D %T'` : $1"
36+
}
37+
38+
#track_error function validates whether the application execute without any error
39+
track_error()
40+
{
41+
if [ $1 != "0" ]; then
42+
log "$2 exited with error code $1"
43+
log "completed execution IN ERROR at `date`"
44+
exit $1
45+
fi
46+
47+
}
48+
49+
#uploading to S3 bucket
50+
upload_cd_pakcage()
51+
{
52+
S3_URL=""
53+
if [ "$AWS_S3_KEY_LOCATION" = "" ] ;
54+
then
55+
S3_URL="s3://${AWS_S3_BUCKET}/"
56+
else
57+
S3_URL="s3://${AWS_S3_BUCKET}/${AWS_S3_KEY_LOCATION}/"
58+
fi
59+
aws s3 cp ${AWS_CD_PACKAGE_NAME} $S3_URL
60+
track_error $? "Package S3 deployment"
61+
log "CD Package uploaded successfully to S3 bucket $S3_URL"
62+
}
63+
#register the revision in Code deploy
64+
update_cd_app_revision()
65+
{
66+
aws deploy register-application-revision --application-name "${AWS_CD_APPNAME}" --s3-location "bucket=${AWS_S3_BUCKET},bundleType=zip,key=${AWS_S3_KEY}"
67+
track_error $? "CD applicaton register"
68+
log "CD application register completed successfully"
69+
}
70+
#Invoke the code deploy
71+
cd_deploy()
72+
{
73+
RESULT=`aws deploy create-deployment --application-name "${AWS_CD_APPNAME}" --deployment-config-name "${AWS_CD_DG_CONFIGURATION}" --deployment-group-name "${AWS_CD_DG_NAME}" --s3-location "bucket=${AWS_S3_BUCKET},bundleType=zip,key=${AWS_S3_KEY}"`
74+
track_error $? "CD applicaton deployment intiation"
75+
DEPLOYID=`echo $RESULT | $JQ .deploymentId`
76+
log "CD application deployment initiation completed successfully. Please find the $DEPLOYID"
77+
}
78+
#Checing the status
79+
cd_deploy_status()
80+
{
81+
echo "check tatusget info aws deploy get-deployment --deployment-id $DEPLOYID"
82+
counter=0
83+
BUFFER=0
84+
DEPLOYMENT_STATUS=`aws deploy get-deployment --deployment-id "$DEPLOYID" | $JQ .deploymentInfo.status`
85+
if [ "$DEPLOYMENT_STATUS" = "Succeeded" ] || [ "$DEPLOYMENT_STATUS" = "Failed" ];
86+
then
87+
BUFFER=1
88+
fi
89+
while [ "$BUFFER" = "0" ]
90+
do
91+
echo "Current Deployment status : $DEPLOYMENT_STATUS"
92+
echo "Waiting for 15 sec to check the Deployment status...."
93+
sleep 15
94+
DEPLOYMENT_STATUS=`aws deploy get-deployment --deployment-id "$DEPLOYID" | $JQ .deploymentInfo.status`
95+
if [ "$DEPLOYMENT_STATUS" = "Succeeded" ] || [ "$DEPLOYMENT_STATUS" = "Failed" ];
96+
then
97+
BUFFER=1
98+
fi
99+
counter=`expr $counter + 1`
100+
if [[ $counter -gt $COUNTER_LIMIT ]] ; then
101+
echo "Deployment does not reach staedy state with in 600 seconds. Please check"
102+
exit 1
103+
fi
104+
done
105+
if [[ "$DEPLOYMENT_STATUS" = "Succeeded" ]] ;
106+
then
107+
echo "Deployment status is $DEPLOYMENT_STATUS"
108+
else
109+
echo "Deployment Failed. Please caheck AWS Code Deploy event logs"
110+
exit 1
111+
fi
112+
113+
}
114+
# configure_aws_cli
115+
upload_cd_pakcage
116+
update_cd_app_revision
117+
if [ "$DEPLOY" = "1" ] ;
118+
then
119+
echo "Proceeding deployment"
120+
else
121+
echo "User skipped deployment by updating the DEPLOY variable other than 1"
122+
exit 0
123+
fi
124+
cd_deploy
125+
cd_deploy_status
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
BACKUP_DIR=/home/web/web_backup
4+
TARGET_JAR=${BACKUP_DIR}/topcoder.jar
5+
BACKUP_JAR=${TARGET_JAR}.bak
6+
# TARGET_JAR1=${BACKUP_DIR}/tc_cache.jar
7+
# BACKUP_JAR1=${TARGET_JAR1}.bak
8+
9+
# app
10+
echo [Taking backup of existing topcoder.jar]
11+
if [ -e $BACKUP_JAR ]; then
12+
rm -rf $BACKUP_JAR
13+
fi
14+
if [ -e $TARGET_JAR ]; then
15+
mv $TARGET_JAR $BACKUP_JAR
16+
fi
17+
18+
# echo [Taking backup of existing tc_cache.jar]
19+
# if [ -e $BACKUP_JAR1 ]; then
20+
# rm -rf $BACKUP_JAR1
21+
# fi
22+
# if [ -e $TARGET_JAR1 ]; then
23+
# mv $TARGET_JAR1 $BACKUP_JAR1
24+
# fi
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
source ~/.bash_profile
4+
5+
pushd /home/web/web
6+
7+
echo "Deploying tc-website"
8+
ant -f build_tc.xml expand
9+
10+
popd

0 commit comments

Comments
 (0)