Skip to content
Merged
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
18 changes: 14 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,22 @@ build_steps: &build_steps
path: ~/junit
- store_artifacts:
path: ~/junit
- run: docker --version
- run:
name: Deploy to AWS
command: |
./awsconfiguration.sh $DEPLOY_ENV
source awsenvconf
chmod +x /home/circleci/project/service/build/deploy.sh
/home/circleci/project/service/build/deploy.sh /home/circleci/project /home/circleci/project/service/build ap-review $DEPLOY_APP_ENV
./service/build/buildimage.sh $DEPLOY_ENV
- deploy:
name: Deploy to AWS
command: |
echo "deploy"
#chmod +x /home/circleci/project/service/build/deploy.sh
#/home/circleci/project/service/build/deploy.sh /home/circleci/project /home/circleci/project/service/build ap-review $DEPLOY_APP_ENV
source awsenvconf
./buildenv.sh -e $DEPLOY_ENV -b ${DEPLOY_ENV}-ap-review-microservice-deployvar
source buildenvvar
./master_deploy.sh -d EBS -e $DEPLOY_ENV -t "${DEPLOY_ENV}.${CIRCLE_BUILD_NUM}"

jobs:
"build-dev":
Expand All @@ -74,7 +82,9 @@ workflows:
context : org-global
filters:
branches:
only: dev
only:
- dev
- dev-msinteg
- "build-prod":
context : org-global
filters:
Expand Down
69 changes: 16 additions & 53 deletions service/build/buildimage.sh
Original file line number Diff line number Diff line change
@@ -1,58 +1,32 @@
#!/usr/bin/env bash
# Define script variables
WORKSPACE=$1
DEPLOY_DIR=$2
SERVICE=$3
APINAME=$3 #ap-review
CONFIG=$4
ENV=$4

#WORKSPACE=$1 #CIRCLE_WORKING_DIRECTORY
#DEPLOY_DIR=$2
#SERVICE=$3
#APINAME=$3 #ap-review
CONFIG=$1
ENV=$1
WORKSPACE=$(eval echo $CIRCLE_WORKING_DIRECTORY)
DEPLOY_DIR=$WORKSPACE/service/build
SERVICE=ap-review
APINAME=ap-review

REPO="${SERVICE}-microservice"
TAG="${REPO}:${CONFIG}.${VER}"
IMAGE="${REGISTRY}/${TAG}"


DOCKER_REPO=appiriodevops
VER=`date "+%Y%m%d%H%M"`
#VER=`date "+%Y%m%d%H%M"`
VER=$CIRCLE_BUILD_NUM
IMAGE="$SERVICE-microservice:$ENV.$VER"

DOCKERRUN_TEMPLATE=$DEPLOY_DIR/Dockerrun.aws.json.template
DOCKERRUN=$DEPLOY_DIR/Dockerrun.aws.json
AWS_S3_BUCKET=appirio-platform-dev
AWS_PROFILE="tc-$ENV"
AWS_S3_KEY="services/docker/$IMAGE"
ENV_JAVA_PARAMS=" "
ENV_CONFIG=`echo "$ENV" | tr '[:lower:]' '[:upper:]'`

AWS_REGION=$(eval "echo \$${ENV_CONFIG}_AWS_REGION")
AWS_ACCESS_KEY_ID=$(eval "echo \$${ENV_CONFIG}_AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY=$(eval "echo \$${ENV_CONFIG}_AWS_SECRET_ACCESS_KEY")

configure_aws_cli() {
aws --version
aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID
aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY
aws configure set default.region $AWS_REGION
aws configure set default.output json
echo "Configured AWS CLI."
}

configure_aws_cli

ENV_CONFIG=`echo "$ENV" | tr '[:upper:]' '[:lower:]'`
ENV=$ENV_CONFIG
# Elastic Beanstalk Application name
# dev
APPNAME="Development"
if [ "$ENV" = "qa" ]; then
APPNAME="QA"
fi
if [ "$ENV" = "prod" ]; then
APPNAME="Production"
AWS_S3_BUCKET=appirio-platform-prod
ENV_JAVA_PARAMS='-Xmx3g -Dnewrelic.environment=production -javaagent:$NEWRELIC_JAR'
fi

echo "deploy dir $DEPLOY_DIR"
cd $DEPLOY_DIR
pwd

echo "Generating Dockerfile"
cat Dockerfile.template | sed -e "s/@ENV_JAVA_PARAMS@/$ENV_JAVA_PARAMS/g" > Dockerfile
Expand All @@ -65,20 +39,9 @@ echo "Copying deployment files to build folder"
cp $WORKSPACE/service/target/review-microservice*.jar review-microservice.jar
cp $WORKSPACE/service/src/main/resources/review-service.yaml review-service.yaml

echo "Generating Docker aws json......."
PLATFORM_BUCKET=appirio-platform-$CONFIG
EBDOCKER_FILENAME=${APINAME}-${CONFIG}.${VER}.aws.json
cat $WORKSPACE/service/build/Dockerrun.aws.json.template | sed -e "s/@IMAGE@/${IMAGE}/g" > ./$EBDOCKER_FILENAME
cat ./$EBDOCKER_FILENAME

echo "copying beanstalk docker file..."
aws s3 cp $EBDOCKER_FILENAME s3://$PLATFORM_BUCKET/services/elasticbeanstalk/

echo "copying dockercfg......"
aws s3 cp "s3://appirio-platform-$ENV/services/common/dockercfg" ~/.dockercfg

echo "Building docker image $DOCKER_REPO/$IMAGE"
docker build -t $DOCKER_REPO/$IMAGE $DEPLOY_DIR

VER1="$ENV.$VER"
echo export TAGNAME="$VER1" >> "$BASH_ENV"