Skip to content

Commit 86b08d0

Browse files
authored
Merge pull request #6 from topcoder-platform/feature_v1.4
Feature v1.4
2 parents e493cc2 + c245abc commit 86b08d0

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

ebs_base_template_v3.json.template

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"AWSEBDockerrunVersion": "1",
3+
"Authentication": {
4+
"Bucket": "@AWSS3AUTHBUCKET@",
5+
"Key": "services/common/dockercfg"
6+
},
7+
"Image": {
8+
"Name": "appiriodevops/@IMAGE@",
9+
"Update": "true"
10+
},
11+
"Ports": [
12+
],
13+
"Volumes": [],
14+
"Logging": ""
15+
}

master_deploy.sh

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ APP_IMAGE_NAME=""
4545
DOCKERRUN="Dockerrun.aws.json"
4646
#EBS_EB_EXTENSTION_LOCATION=""
4747
IMG_WITH_EBS_TAG=""
48-
EBS_TEMPLATE_SKELETON_FILE="ebs_base_template_v2.json.template"
48+
EBS_TEMPLATE_SKELETON_FILE="ebs_base_template_v3.json.template"
4949
EBS_APPLICATION_NAME=""
5050
EBS_APPVER=""
5151
EBS_TAG=""
@@ -58,7 +58,8 @@ EBS_TEMPLATE_FILE_NAME=""
5858
#AWS_EBS_EB_DOCKERRUN_TEMPLATE_LOCATION=$(eval "echo \$${ENV}_AWS_EBS_EB_DOCKERRUN_TEMPLATE_LOCATION")
5959
#AWS_EBS_DOCKERRUN_TEMPLATE=$(eval "echo \$${ENV}_AWS_EBS_DOCKERRUN_TEMPLATE")
6060
#AWS_S3_KEY_LOCATION=""
61-
61+
ebsportcount=0
62+
ebstemplate=""
6263
#variable for cloud front
6364
#AWS_S3_BUCKET=""
6465
#AWS_S3_SOURCE_SYNC_PATH=""
@@ -418,6 +419,22 @@ validate_update_loggroup()
418419
}
419420
# EBS integration
420421

422+
ebsportmapping() {
423+
echo "port map called"
424+
containerport=$1
425+
hostport=$2
426+
427+
if [ -z $hostport ]
428+
then
429+
ebstemplate=$(echo $ebstemplate | jq --arg containerPort $containerport --arg ebsportcount $ebsportcount '.Ports[$ebsportcount |tonumber] |= .+ { ContainerPort: $containerPort }')
430+
else
431+
ebstemplate=$(echo $ebstemplate | jq --arg hostPort $hostport --arg containerPort $containerport --arg ebsportcount $ebsportcount '.Ports[$ebsportcount |tonumber] |= .+ { HostPort: $hostPort, ContainerPort: $containerPort }')
432+
fi
433+
434+
let ebsportcount=ebsportcount+1
435+
436+
}
437+
421438

422439
EBS_push_docker_image() {
423440

@@ -433,6 +450,26 @@ creating_updating_ebs_docker_json() {
433450
sed -i.bak -e "s/@AWSS3AUTHBUCKET@/appirio-platform-$ENV_CONFIG/g" $EBS_TEMPLATE_SKELETON_FILE
434451
rm ${EBS_TEMPLATE_SKELETON_FILE}.bak
435452

453+
#EBS Port Mapping
454+
ebstemplate=$(cat $EBS_TEMPLATE_SKELETON_FILE)
455+
if [ -z $AWS_EBS_PORTS ];
456+
then
457+
echo "No container port is defined. configuring default 8080 port"
458+
ebsportmapping 8080
459+
else
460+
Buffer_portmap=$(echo $AWS_EBS_PORTS | sed 's/,/ /g')
461+
for ebsportbuf in $Buffer_portmap;
462+
do
463+
containerport=$( echo $ebsportbuf | cut -d ':' -f 1 )
464+
if [[ $ebsportbuf = *:* ]]; then
465+
hostport=$( echo $ebsportbuf | cut -d ':' -f 2 )
466+
fi
467+
ebsportmapping $containerport $hostport
468+
done
469+
fi
470+
echo "$ebstemplate" > $EBS_TEMPLATE_SKELETON_FILE
471+
log "port mapping updated"
472+
436473
if [ -z "$EBS_EB_EXTENSTION_LOCATION" ];
437474
then
438475
cat $EBS_TEMPLATE_SKELETON_FILE | sed -e "s/@IMAGE@/${IMG_WITH_EBS_TAG}/g" > $DOCKERRUN

0 commit comments

Comments
 (0)