This sample demonstrates how to setup continuous integration and deployment for a Node.js+MongoDB project deployed using Amazon Elastic Beanstalk. Additionally, it shows how to deploy different branches to separate Elastic Beanstalk environments.
Two approaches are available for handling deployment to multiple environments:
-
Use
eb use <env name>command to associate your current branch with some environment. Then, copy.elasticbeanstalk/config.ymlfile asconfig.yml. You can also editconfig.ymlfile manually. For example, to associateprodbranch withsample-nodejs-env-prod, add the following entry to yourconfig.ymlfile:branch-defaults: ebcli-v3: environment: sample-nodejs-env prod: environment: sample-nodejs-env-prod
Now, whenever eb deploy command is executed while the current branch is prod, it will automatically push the designated environment.
-
Pass the environment as an argument to
eb deploycommand in yourafter_successblock. You can choose the correct environment based on the value of the Shippable-suppliedBRANCHvariable:- > if [ $BRANCH = 'prod' ]; then ENV='sample-nodejs-env-prod' else ENV='sample-nodejs-env' fi - eb init && eb deploy $ENV
For more detailed documentation, please see Shippable's continuous deployment section. http://docs.shippable.com/en/latest/config.html#continuous-deployment
This sample is built for Shippable, a docker based continuous integration and deployment platform.