Created
March 16, 2015 18:00
-
-
Save gmas/660d75875b10a3599741 to your computer and use it in GitHub Desktop.
deploy to Beanstalk through Dockerhub
This file contains hidden or 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
#! /bin/bash | |
SHA1=$1 | |
BUILD_NUM=$2 | |
# Push image to Docker Registry | |
docker commit `docker run -d portaldev_web` $DOCKER_REPO:$SHA1 | |
docker push $DOCKER_REPO:$SHA1 | |
# Create Elastic Beanstalk zipped source bundle | |
DOCKERRUN_FILE=Dockerrun.aws.json | |
SRCBUNDLE_FILE="$SHA1"_source_bundle.zip | |
# Interpolate AWS params in Nginx SSL config file | |
sed -e "s/<EB_BUCKET>/$EB_BUCKET/" -e "s/<EB_AWS_REGION>/$EB_AWS_REGION/" < .ebextensions/01ssl.config.template > .ebextensions/01ssl.config | |
# Interpolate New Relic variables to deployment notification script. | |
sed -e "s/<NEW_RELIC_API_KEY>/$NEW_RELIC_API_KEY/" -e "s/<NEW_RELIC_APP_NAME>/$NEW_RELIC_APP_NAME/" -e "s/<NEW_RELIC_DEPLOYMENT_SHA>/$SHA1/" -e "s/<NEW_RELIC_CIRCLE_BUILD_NUM>/$BUILD_NUM/" < .ebextensions/03.deployment_notification.config.template > .ebextensions/03.deployment_notification.config | |
# Interpolate params in ElasticBeanstalk deploy file | |
sed -e "s/<TAG>/$SHA1/" -e "s/<EB_BUCKET>/$EB_BUCKET/" < Dockerrun.aws.json.template > $DOCKERRUN_FILE | |
zip $SRCBUNDLE_FILE $DOCKERRUN_FILE .ebextensions/*.config | |
# Upload ElasticBeanstalk source bundle | |
aws s3 cp $SRCBUNDLE_FILE s3://$EB_BUCKET/$SRCBUNDLE_FILE | |
# Deploy new version to ElasticBeanstalk | |
aws elasticbeanstalk create-application-version --application-name "$APP_NAME" \ | |
--version-label $SHA1 --source-bundle S3Bucket=$EB_BUCKET,S3Key=$SRCBUNDLE_FILE | |
# Update ElasticBeanstalk environment to new version | |
aws elasticbeanstalk update-environment --environment-name $ENV_NAME --version-label $SHA1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment