Deploying Containers to Elastic Beanstalk, the Shippable way!  

- By Raghu Gollamudi on September 18, 2015

 

 

Warning-Icon.png

DEPRECATED BLOG:

We have significantly updated the Shippable platform with several new features. Hence most of the content in this blog is deprecated. For the latest information, refer to our documentation and/or open a support issue, if you have questions.

You can also refer to our new blog on this topic: How To: Deploy your application to AWS Elastic Beanstalk (Part 1)


 

 

Last month we introduced the ability to deploy Docker containers to Amazon AWS Elastic Beanstalk (EBS) as the last step in a Shippable CI/CD pipeline.  In this article, I will walk through the steps required to set this up in Shippable and execute a deployment to EBS.

AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.

Over the last couple of years, we’ve observed many of our customers deploying to EBS, which is no surprise since, in a recent survey by Goldman Sachs, EBS is the most used public PaaS offering.  With our release last month of native support for deploying to EBS, our goal is to make this easy to accomplish with a few settings. Instead of encrypting keys and specifying scripts in Shippable.yml, you can now configure your AWS integration and link it to your project. Once configured, a successful build will automatically trigger the creation of a new application version, which will subsequently update the EBS environment.

Here’s a sample deployment workflow representing how this would work on Shippable:

 

 

Here’s how you configure EBS deployments on Shippable:

Step 1 : Create AWS Integration
First you will have to create an AWS integration, which is done in the Shippable Account settings.  You’ll find these settings via the settings icon in the upper right of the top-nav. Once on the Settings screen, click on the Integrations tab:

 

To add the new integration, click the "+" icon, enter a name for the integration and select "AWS" from the ‘Master Integration’ drop-down list. The AWS integration will contain your AWS credential information to access the EBS instance:

 

After this, you will be prompted to enter your access and secret keys. These keys are provided by AWS and you can find more info here on how to generate them (make sure that these keys have access to your EBS instance). Enter the region of your EBS instance and save the integration. Once saved, this integration is available to all your projects.

 

Step 2: Configure EBS deployment
Next you will have to configure EBS deployments for a project. To do this, navigate to the project dashboard page and click on the settings tab. In the settings tab you will find the deployment section where you can configure the EBS deployment settings.

 

Click on “Add Deployment” and select “Elastic Beanstalk” from the drop-down list. Link the AWS integration created in step 1 and enter the Application, the Environment and the S3 bucket names. The S3 bucket is required to copy artifacts, which EBS will use during deployment. I will explain this further in step 3. Clicking on save will activate EBS deployments for the project

 

Step 3: Create Dockerrun.aws.json

In this step you will have to create a "Dockerrun.aws.json" (case sensitive) file in the root folder of your source-code. You can find a sample file here. We look for "<IMAGE_NAME>" and "<TAG>" tokens and replace them with values derived from project settings and build information. A new file with the name Dockerrun.aws.json.<branch>.buildnumber is generated, which is then copied to the S3 bucket.

 

You have now completed configuring EBS deployments for your project. When you run a build you should see console logs related to EBS deployment. Take a look at the image below for more info. 

Let us know if you have any feedback or questions as you implement this at your end. We also have detailed documentation on all our features on our Docs page.

Happy Shipping! 

 

Topics: Docker, continuous deployment (CD), containers