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
19 changes: 19 additions & 0 deletions service/build/Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM appiriodevops/ap-microservice-base:0.0.1

MAINTAINER mdesiderio@appirio.com

WORKDIR /data

COPY review-microservice.jar /data/review-microservice.jar

COPY review-service.yaml /data/review-service.yaml

COPY newrelic.yml /usr/local/share/newrelic/newrelic.yml

COPY sumo-sources.json /data/sumo-sources.json

COPY sumo.conf /etc/sumo.conf

CMD /bin/bash /usr/local/share/sumocollector/collector start && java @ENV_JAVA_PARAMS@ -Ddw.authDomain="$AUTH_DOMAIN" -Ddw.databases[0].password="$OLTP_PW" -Ddw.databases[0].url="$OLTP_URL" -Ddw.databases[1].password="$DW_PW" -Ddw.databases[1].url="$DW_URL" -jar /data/review-microservice.jar server /data/review-service.yaml

EXPOSE 8080 8081 2181 9092
19 changes: 19 additions & 0 deletions service/build/Dockerrun.aws.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"AWSEBDockerrunVersion": "1",
"Authentication": {
"Bucket": "appirio-platform-dev",
"Key": "services/common/dockercfg"
},
"Image": {
"Name": "appiriodevops/@IMAGE@",
"Update": "true"
},
"Ports": [
{
"ContainerPort": "8080"
}
],
"Volumes": [
],
"Logging": ""
}
62 changes: 62 additions & 0 deletions service/build/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Define script variables
WORKSPACE=$1
DEPLOY_DIR=$2
SERVICE=$3
ENV=$4

DOCKER_REPO=appiriodevops
VER=`date "+%Y%m%d%H%M"`
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=" "

# 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

cd $DEPLOY_DIR

echo "Generating Dockerfile"
cat Dockerfile.template | sed -e "s/@ENV_JAVA_PARAMS@/$ENV_JAVA_PARAMS/g" > Dockerfile

echo "Generate sumo config files"
cat sumo.conf.template | sed -e "s/@env@/${ENV}/g" > sumo.conf
cat sumo-sources.json.template | sed -e "s/@env@/${ENV}/g" > sumo-sources.json

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 "Building docker image $DOCKER_REPO/$IMAGE"
sudo docker build -t $DOCKER_REPO/$IMAGE $DEPLOY_DIR

echo "Pushing image to docker $DOCKER_REPO/$IMAGE"
sudo docker push $DOCKER_REPO/$IMAGE

echo "Generating dockerrun file"
cat $DOCKERRUN_TEMPLATE | sed -e "s/@IMAGE@/${IMAGE}/g" > $DOCKERRUN

echo "Uploading dockerrun file to aws"

echo "Pushing Dockerrun.aws.json to S3: ${AWS_S3_BUCKET}/${AWS_S3_KEY}"
aws s3api put-object --profile $AWS_PROFILE --bucket "${AWS_S3_BUCKET}" --key "${AWS_S3_KEY}" --body $DOCKERRUN

echo "Creating new application version $IMAGE in $APPNAME from s3:${AWS_S3_BUCKET}/${AWS_S3_KEY}"
aws elasticbeanstalk create-application-version --profile $AWS_PROFILE --application-name $APPNAME --version-label $IMAGE --source-bundle S3Bucket="$AWS_S3_BUCKET",S3Key="$AWS_S3_KEY"

echo "updating elastic beanstalk environment ${AWS_EB_ENV} with the version $IMAGE."
# assumes beanstalk app for this service has already been created and configured
aws elasticbeanstalk --profile $AWS_PROFILE update-environment --environment-name $SERVICE-$ENV --version-label $IMAGE
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,4 @@ test:
app_name: ap-review (Test)

production:
<<: *default_settings
<<: *default_settings
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"api.version": "v1",
"sources": [
{
"name": "ap-review-prod",
"name": "ap-review-@env@",
"sourceType": "LocalFile",
"multilineProcessingEnabled": false,
"pathExpression": "/var/log/ap-review.log",
"category": "prod",
"category": "@env@",
"hostName": "ap-review"
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name=ap-review-prod
name=ap-review-@env@
accessid=suMochTM9jsUmo
accesskey=i9Jo6vJ8TiGH4NLJ6JOrhR2Z34eKZQcDNCiGz5ePkujZWwzzZhcAZNufty6viT63
clobber=true
Expand Down
19 changes: 0 additions & 19 deletions service/run-config/dev/build/Dockerfile

This file was deleted.

Loading