This is a skeleton repository that can be used for testing or as a quick way for you to incorporate Nubis into your own project.
If you are new to the Nubisproject you will need to set up some prerequisites.
Next grab the latest release, extract it and copy the nubis directory into your code base.
These are convenience steps to make the following commands a bit more manageable.
Be sure to replace <login>
with your login name. You may also need to adjust
the account name and number if you are not building in the Nubis training
account.
ACCOUNT_NAME='nubis-training'; ACCOUNT_NUMBER='517826968395'; LOGIN='<login>'
alias vault-exec="aws-vault exec ${ACCOUNT_NAME}-admin --"
NUBIS_DOCKER=( 'docker' 'run' \
'-u' "$UID:$(id -g)" \
'--interactive' \
'--tty' \
'--env-file' "$(echo ~)/.docker_env" \
'-v' "$PWD:/nubis/data" )
Run nubis-builder and it will output an AMI id for you to use.
NUBIS_BUILD_VERSION=$(curl -k -s -S \
https://registry.hub.docker.com/v1/repositories/nubisproject/nubis-builder/tags \
| jq --raw-output '.[]["name"]' | \
sort --field-separator=. --numeric-sort --reverse | \
grep -m 1 "^v")
vault-exec "${NUBIS_DOCKER[@]}" -e GIT_COMMIT_SHA=$(git rev-parse HEAD) \
"nubisproject/nubis-builder:${NUBIS_BUILD_VERSION}"
Create a nubis/terraform/terraform.tfvars file by copying the terraform.tfvars-dist file and editing the parameter values. More detailed instructions can be found here. NOTE: Be sure to use the AMI id you got from the build step.
cp nubis/terraform/terraform.tfvars-dist nubis/terraform/terraform.tfvars
vi nubis/terraform/terraform.tfvars
You are now ready to deploy your application. Once you have tested, be sure to destroy the deployment to avoid unnecessary cost in AWS.
NUBIS_DEPLOY_VERSION=$(curl -k -s -S \
https://registry.hub.docker.com/v1/repositories/nubisproject/nubis-release/tags \
| jq --raw-output '.[]["name"]' | \
sort --field-separator=. --numeric-sort --reverse | \
grep -m 1 "^v")
vault-exec "${NUBIS_DOCKER[@]}" \
"nubisproject/nubis-deploy:${NUBIS_DEPLOY_VERSION}" plan
vault-exec "${NUBIS_DOCKER[@]}" \
"nubisproject/nubis-deploy:${NUBIS_DEPLOY_VERSION}" apply
Terraform creates a route53 hosted zone and a cname record. And the resulting url will be part of the outputs:
Outputs:
address = https://www.<service_name>-<env>.<env>.<region>.<account_name>.nubis.allizom.org/
If you have only one EC2 instance and your ssh keys are on the jumphost, you can login by:
ssh -A -t <login>@jumphost.<env>.core.<region>.<account-name>.nubis.allizom.org \
"ssh -A -t ubuntu@<service_name>.service.consul"
Lastly, clean up the deployment which helps reduce cost , and it is just tidy.
vault-exec "${NUBIS_DOCKER[@]}" \
"nubisproject/nubis-deploy:${NUBIS_DEPLOY_VERSION}" destroy
If you run into any issues, feel free to reach out to us. We hang out in #nubis-users on Slack.