-
-
Notifications
You must be signed in to change notification settings - Fork 20
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 #781 from AlexsLemonade/dev
Release latest changes to master
- Loading branch information
Showing
73 changed files
with
2,024 additions
and
570 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,12 +1,5 @@ | ||
# Install git-crypt | ||
cd | ||
git clone https://github.com/AGWA/git-crypt.git | ||
cd git-crypt | ||
make | ||
sudo make install | ||
|
||
# Unlock encrypted files | ||
cd ~/refinebio/.circleci | ||
openssl aes-256-cbc -d -in exported.key.enc -out $KEY_FILENAME -k $OPENSSL_KEY | ||
openssl aes-256-cbc -md md5 -d -in exported.key.enc -out $KEY_FILENAME -k $OPENSSL_KEY | ||
git-crypt unlock $KEY_FILENAME | ||
rm -f $KEY_FILENAME |
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,8 @@ | ||
#!/bin/bash | ||
|
||
# Install git-crypt | ||
cd | ||
git clone https://github.com/AGWA/git-crypt.git | ||
cd git-crypt | ||
make | ||
sudo make install |
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,69 @@ | ||
#!/bin/bash -e | ||
|
||
# This script will deploy the Refinebio system using a dedicated AWS instance. | ||
# First it will use that instance to build up to date Docker images | ||
# and push them to Dockerhub. | ||
# Next it will use terraform to update our infrastructure and restart our services. | ||
# Finally it cleans up after itself. | ||
|
||
# It has been written with the intention of being run from CircleCI as | ||
# part of our CI/CD process. It therefore assumes that the following | ||
# environment variables will be set: | ||
# - DEPLOY_IP_ADDRESS -- The IP address of the instance to run the deploy on. | ||
# - CIRCLE_TAG -- The tag that was pushed to CircleCI to trigger the deploy. | ||
# Will be used as the version for the system and the tag for Docker images. | ||
# - DOCKER_ID -- The username that will be used to log into Dockerhub. | ||
# - DOCKER_PASSWD -- The password that will be used to log into Dockerhub. | ||
# - KEY_FILENNAME -- The name to use for the decrypted SSH key file. | ||
# - OPENSSL_KEY -- The OpenSSl key which will be used to decrypt the SSH key. | ||
# - AWS_ACCESS_KEY_ID -- The AWS key id to use when interacting with AWS. | ||
# - AWS_SECRET_ACCESS_KEY -- The AWS secret key to use when interacting with AWS. | ||
|
||
|
||
cd ~/refinebio | ||
|
||
chmod 600 infrastructure/data-refinery-key.pem | ||
|
||
run_on_deploy_box () { | ||
ssh -o StrictHostKeyChecking=no \ | ||
-i infrastructure/data-refinery-key.pem \ | ||
ubuntu@${DEPLOY_IP_ADDRESS} "cd refinebio && $1" | ||
} | ||
|
||
# Create file containing local env vars that are needed for deploy. | ||
rm -f env_vars | ||
echo "export CIRCLE_TAG=$CIRCLE_TAG" >> env_vars | ||
echo "export DOCKER_ID=$DOCKER_ID" >> env_vars | ||
echo "export DOCKER_PASSWD=$DOCKER_PASSWD" >> env_vars | ||
echo "export KEY_FILENAME=$KEY_FILENAME" >> env_vars | ||
echo "export OPENSSL_KEY=$OPENSSL_KEY" >> env_vars | ||
echo "export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" >> env_vars | ||
echo "export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" >> env_vars | ||
|
||
# And checkout the correct tag. | ||
run_on_deploy_box "git fetch" | ||
run_on_deploy_box "git checkout $CIRCLE_TAG" | ||
|
||
# Verify that the tag has been signed by a trusted team member. | ||
run_on_deploy_box "bash .circleci/verify_tag.sh" | ||
|
||
# Copy the necessary environment variables over. | ||
scp -o StrictHostKeyChecking=no \ | ||
-i infrastructure/data-refinery-key.pem \ | ||
-r env_vars ubuntu@$DEPLOY_IP_ADDRESS:refinebio/env_vars | ||
|
||
# Decrypt the secrets in our repo. | ||
run_on_deploy_box "source env_vars && bash .circleci/git_decrypt.sh" | ||
|
||
run_on_deploy_box "source env_vars && echo -e '######\nBuilding new images for $CIRCLE_TAG\n######' &>> /var/log/docker_update.log 2>&1" | ||
run_on_deploy_box "source env_vars && bash .circleci/update_docker_img.sh >> /var/log/docker_update.log 2>&1" | ||
run_on_deploy_box "source env_vars && echo -e '######\nFinished building new images for $CIRCLE_TAG\n######' &>> /var/log/docker_update.log 2>&1" | ||
|
||
run_on_deploy_box "source env_vars && echo -e '######\nStarting new deploy for $CIRCLE_TAG\n######' >> /var/log/deploy.log 2>&1" | ||
run_on_deploy_box "source env_vars && bash .circleci/run_terraform.sh >> /var/log/deploy.log 2>&1" | ||
run_on_deploy_box "source env_vars && echo -e '######\nDeploying $CIRCLE_TAG finished!\n######' >> /var/log/deploy.log 2>&1" | ||
|
||
# Don't leave secrets lying around. | ||
## Clean out any files we've created or moved so git-crypt will relock the repo. | ||
run_on_deploy_box "git clean -f" | ||
run_on_deploy_box "git-crypt lock" |
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
Oops, something went wrong.