-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from xogroup/feature/support_worker_web-7
Adds features to support web vs worker deploys
- Loading branch information
Showing
12 changed files
with
259 additions
and
71 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1 @@ | ||
#!/usr/bin/env bash | ||
|
||
#Set up the variables needed | ||
VERSION=`cat ./VERSION` | ||
APP_NAME=`cat ./APP_NAME` | ||
APP_ENV=$1 #Environment (qa/prod) | ||
TYPE=$2 #Type (web/worker) | ||
APP_ENV_FULL=`if [ $APP_ENV = prod ]; then echo production; else echo $APP_ENV; fi` | ||
AWS_KEY=`aws configure get aws_access_key_id` | ||
AWS_SECRET=`aws configure get aws_secret_access_key` | ||
AWS_REGION=`aws configure get region` | ||
|
||
#Copy the appropriate Dockerrun file to the root | ||
cp ./scripts/docker/$APP_ENV-Dockerrun.aws.json ./Dockerrun.aws.json | ||
git add Dockerrun.aws.json | ||
|
||
#Try to use the current eb environment | ||
#If it exists deploy to existing environment | ||
#If not then create a new one (blue/green deployment) | ||
errors=`eb use $APP_ENV-$APP_NAME-$VERSION-$TYPE | grep "ERROR: Environment"` | ||
if [$errors == ""]; then | ||
eb deploy $APP_ENV-$APP_NAME-$VERSION-$TYPE --timeout 30 --staged | ||
else | ||
eb create $APP_ENV-$APP_NAME-$VERSION-$TYPE \ | ||
--tags Name=$APP_ENV-$APP_NAME \ | ||
--cfg $APP_NAME-$APP_ENV \ | ||
-c $APP_ENV-$APP_NAME-$VERSION-$TYPE \ | ||
--timeout 15 \ | ||
--envvars AWS_ACCESS_KEY_ID=$AWS_KEY,\ | ||
AWS_SECRET_ACCESS_KEY=$AWS_SECRET,\ | ||
AWS_REGION=$AWS_REGION,\ | ||
SECRET_KEY_BASE=$SECRET_KEY_BASE,\ | ||
WEB_TYPE=$TYPE,\ | ||
RAILS_ENV=$APP_ENV_FULL,\ | ||
RAKE_ENV=$APP_ENV_FULL,\ | ||
WEB_CONCURRENCY=3 | ||
fi | ||
##This will be replaced based on whether it's a web or worker |
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#Will be replaced by the web/worker script for ruby |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/env bash | ||
|
||
raw_environment_name=$1 | ||
raw_environment_type=$2 | ||
AWS_ACCESS_KEY_ID=`aws configure get aws_access_key_id` | ||
AWS_SECRET_ACCESS_KEY=`aws configure get aws_secret_access_key` | ||
AWS_REGION=`aws configure get region` | ||
|
||
function qualified_environment_name { | ||
echo $raw_environment_name-$(app_name)-$(app_version)-$raw_environment_type | sed 's/_/-/g' | sed 's/\./-/g' | ||
} | ||
|
||
function qualified_rails_environment_name { | ||
if [ $raw_environment_name == prod ]; then echo production; else echo $raw_environment_name; fi | ||
} | ||
|
||
function secret_key_base { | ||
echo $(base64 /dev/urandom | head -c 60) | ||
} | ||
|
||
function app_version { | ||
cat ./VERSION | ||
} | ||
|
||
function app_name { | ||
cat ./APP_NAME | ||
} | ||
|
||
function is_existing_environment { | ||
errors=$(eb use $(qualified_environment_name) | grep "ERROR: Environment") | ||
if [$errors == ""]; then return 0; else return 1; fi | ||
} | ||
|
||
function qualified_instance_type { | ||
if [ $raw_environment_name == 'prod' ]; then echo 't2.medium'; else echo 't2.micro'; fi | ||
} | ||
|
||
#Copy the appropriate Dockerrun file to the root | ||
cp ./scripts/docker/$raw_environment_name-Dockerrun.aws.json ./Dockerrun.aws.json | ||
git add Dockerrun.aws.json | ||
|
||
#Try to use the current eb environment | ||
#If it exists deploy to existing environment | ||
#If not then create a new one (blue/green deployment) | ||
if is_existing_environment; then | ||
echo "Deploy" | ||
eb deploy $(qualified_environment_name) --timeout 30 --staged | ||
else | ||
echo "Create" | ||
eb create $(qualified_environment_name) \ | ||
-c $(qualified_environment_name) | ||
-t web \ | ||
-i $(qualified_instance_type) \ | ||
--tags Name=$(app_name),Team='Your Team Here',Application='$(app_name)',Environment=$(qualified_rails_environment_name),Role='Web' \ | ||
--envvars AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY,AWS_REGION=$AWS_REGION,SECRET_KEY_BASE=$(secret_key_base),RAILS_ENV=$(qualified_rails_environment_name),RACK_ENV=$(qualified_rails_environment_name) \ | ||
--vpc.id 'vpc-12344' \ | ||
--vpc.dbsubnets 'subnet-12345' \ | ||
--vpc.ec2subnets 'subnet-12345 \ | ||
--vpc.elbpublic \ | ||
--vpc.publicip \ | ||
--vpc.securitygroups 'sg-1235' \ | ||
-k 'ec2-key-here' \ | ||
-ip 'some_instance_profile' \ | ||
--timeout 15 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env bash | ||
|
||
raw_environment_name=$1 | ||
raw_environment_type=$2 | ||
AWS_ACCESS_KEY_ID=`aws configure get aws_access_key_id` | ||
AWS_SECRET_ACCESS_KEY=`aws configure get aws_secret_access_key` | ||
AWS_REGION=`aws configure get region` | ||
|
||
function qualified_environment_name { | ||
echo $raw_environment_name-$(app_name)-$(app_version)-$raw_environment_type | sed 's/_/-/g' | sed 's/\./-/g' | ||
} | ||
|
||
function qualified_rails_environment_name { | ||
if [ $raw_environment_name == prod ]; then echo production; else echo $raw_environment_name; fi | ||
} | ||
|
||
function secret_key_base { | ||
echo $(base64 /dev/urandom | head -c 60) | ||
} | ||
|
||
function app_version { | ||
cat ./VERSION | ||
} | ||
|
||
function app_name { | ||
cat ./APP_NAME | ||
} | ||
|
||
function is_existing_environment { | ||
errors=$(eb use $(qualified_environment_name) | grep "ERROR: Environment") | ||
if [$errors == ""]; then return 0; else return 1; fi | ||
} | ||
|
||
function qualified_instance_type { | ||
if [ $raw_environment_name == 'prod' ]; then echo 't2.medium'; else echo 't2.micro'; fi | ||
} | ||
|
||
#Copy the appropriate Dockerrun file to the root | ||
cp ./scripts/docker/$raw_environment_name-Dockerrun.aws.json ./Dockerrun.aws.json | ||
git add Dockerrun.aws.json | ||
|
||
#Try to use the current eb environment | ||
#If it exists deploy to existing environment | ||
#If not then create a new one (blue/green deployment) | ||
if is_existing_environment; then | ||
echo "Deploy" | ||
eb deploy $(qualified_environment_name) --timeout 30 --staged | ||
else | ||
echo "Create" | ||
eb create $(qualified_environment_name) \ | ||
-t worker \ | ||
-i $(qualified_instance_type) \ | ||
--tags Name=$(app_name),Team='Your Team Here',Application='$(app_name)',Environment=$(qualified_rails_environment_name),Role='Web' \ | ||
--envvars AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY,AWS_REGION=$AWS_REGION,SECRET_KEY_BASE=$(secret_key_base),RAILS_ENV=$(qualified_rails_environment_name),RACK_ENV=$(qualified_rails_environment_name) \ | ||
--vpc.id 'vpc-12344' \ | ||
--vpc.dbsubnets 'subnet-12345' \ | ||
--vpc.ec2subnets 'subnet-12345 \ | ||
--vpc.elbpublic \ | ||
--vpc.publicip \ | ||
--vpc.securitygroups 'sg-1235' \ | ||
-k 'ec2-key-here' \ | ||
-ip 'some_instance_profile' \ | ||
--timeout 15 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
raw_environment_name=$1 | ||
raw_environment_type=$2 | ||
AWS_ACCESS_KEY_ID=`aws configure get aws_access_key_id` | ||
AWS_SECRET_ACCESS_KEY=`aws configure get aws_secret_access_key` | ||
AWS_REGION=`aws configure get region` | ||
|
||
function qualified_environment_name { | ||
echo $raw_environment_name-$(app_name)-$(app_version)-$raw_environment_type | sed 's/_/-/g' | sed 's/\./-/g' | ||
} | ||
|
||
function app_version { | ||
cat ./VERSION | ||
} | ||
|
||
function app_name { | ||
cat ./APP_NAME | ||
} | ||
|
||
function is_existing_environment { | ||
errors=$(eb use $(qualified_environment_name) | grep "ERROR: Environment") | ||
if [$errors == ""]; then return 0; else return 1; fi | ||
} | ||
|
||
function qualified_instance_type { | ||
if [ $raw_environment_name == 'prod' ]; then echo 't2.medium'; else echo 't2.micro'; fi | ||
} | ||
|
||
#Copy the appropriate Dockerrun file to the root | ||
cp ./scripts/docker/$raw_environment_name-Dockerrun.aws.json ./Dockerrun.aws.json | ||
git add Dockerrun.aws.json | ||
|
||
#Try to use the current eb environment | ||
#If it exists deploy to existing environment | ||
#If not then create a new one (blue/green deployment) | ||
if is_existing_environment; then | ||
echo "Deploy" | ||
eb deploy $(qualified_environment_name) --timeout 30 --staged | ||
else | ||
echo "Create" | ||
eb create $(qualified_environment_name) \ | ||
-c $(qualified_environment_name) | ||
-t web \ | ||
-i $(qualified_instance_type) \ | ||
--tags Name=$(app_name),Team='Your Team Here',Application='$(app_name)',Environment=$(qualified_environment_name),Role='Web' \ | ||
--envvars AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY,AWS_REGION=$AWS_REGION \ | ||
--vpc.id 'vpc-12344' \ | ||
--vpc.dbsubnets 'subnet-12345' \ | ||
--vpc.ec2subnets 'subnet-12345 \ | ||
--vpc.elbpublic \ | ||
--vpc.publicip \ | ||
--vpc.securitygroups 'sg-1235' \ | ||
-k 'ec2-key-here' \ | ||
-ip 'some_instance_profile' \ | ||
--timeout 15 | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
raw_environment_name=$1 | ||
raw_environment_type=$2 | ||
AWS_ACCESS_KEY_ID=`aws configure get aws_access_key_id` | ||
AWS_SECRET_ACCESS_KEY=`aws configure get aws_secret_access_key` | ||
AWS_REGION=`aws configure get region` | ||
|
||
function qualified_environment_name { | ||
echo $raw_environment_name-$(app_name)-$(app_version)-$raw_environment_type | sed 's/_/-/g' | sed 's/\./-/g' | ||
} | ||
|
||
function app_version { | ||
cat ./VERSION | ||
} | ||
|
||
function app_name { | ||
cat ./APP_NAME | ||
} | ||
|
||
function is_existing_environment { | ||
errors=$(eb use $(qualified_environment_name) | grep "ERROR: Environment") | ||
if [$errors == ""]; then return 0; else return 1; fi | ||
} | ||
|
||
function qualified_instance_type { | ||
if [ $raw_environment_name == 'prod' ]; then echo 't2.medium'; else echo 't2.micro'; fi | ||
} | ||
|
||
#Copy the appropriate Dockerrun file to the root | ||
cp ./scripts/docker/$raw_environment_name-Dockerrun.aws.json ./Dockerrun.aws.json | ||
git add Dockerrun.aws.json | ||
|
||
#Try to use the current eb environment | ||
#If it exists deploy to existing environment | ||
#If not then create a new one (blue/green deployment) | ||
if is_existing_environment; then | ||
echo "Deploy" | ||
eb deploy $(qualified_environment_name) --timeout 30 --staged | ||
else | ||
echo "Create" | ||
eb create $(qualified_environment_name) \ | ||
-t worker \ | ||
-i $(qualified_instance_type) \ | ||
--tags Name=$(app_name),Team='Your Team Here',Application='$(app_name)',Environment=$(qualified_environment_name),Role='Web' \ | ||
--envvars AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY,AWS_REGION=$AWS_REGION \ | ||
--vpc.id 'vpc-12344' \ | ||
--vpc.dbsubnets 'subnet-12345' \ | ||
--vpc.ec2subnets 'subnet-12345 \ | ||
--vpc.elbpublic \ | ||
--vpc.publicip \ | ||
--vpc.securitygroups 'sg-1235' \ | ||
-k 'ec2-key-here' \ | ||
-ip 'some_instance_profile' \ | ||
--timeout 15 | ||
fi |