The Shippable Blog

Specifying Deployment Targets for Different Git Branches

So, you already have Shippable setup for all your CI needs, and you're itching to take the plunge into CD? Maybe the thing that's been holding you back is you aren't sure how you can easily deploy to your dev, staging, and prod machines, without accidently pushing to production prematurely? The good news is Shippable can easily be setup to accommodate such a work flow! You can specify different deployment procedures based on your git branch.

Let's say you want to use want Shippable to perform a build for every commit, but you only want to do a deployment if it's a commit to the master branch. We keep track of what branch was pushed to via the BRANCH environment variable; This environment  variable can be used to implement branch specific logic. Here is an example shippable.yml snippet:

env:
global:
- APP_NAME_PROD=shroudd-headland-1758

after_success:
- if [ "$BRANCH" == "master" ]; then git push -f git@heroku.com:$APP_NAME_PROD.git master; fi

This will push your app to Heroku, but will only do so for successful builds from the master branch. For those unfamiliar with using Shippable for continuous deployment to Heroku, please refer to our documentation.

This basic idea can be extended in many ways! For example, you could send commits from master to prod, and all other commits to dev:

AWS Code Deploy and Shippable

Here at Shippable, we have a strong history of working well with AWS workflows. With the recent release of AWS Code deploy, we wanted to take some time to let you know how easily you can use Shippable and Code Deploy together in your continuous deployment workflow!

First off, there are some prerequisites before your Shippable minions can trigger Code Deploy. On your AWS account, you must have the following setup:

  • An S3 bucket or Github repo to hold your project
  • Your AWS account's access and secret keys
  • A Code Deploy Application, Deployment group, and underlying EC2 resources

If you have any question on the above requirements, AWS provides detailed instruction on obtaining keys and setting up Code Deploy.

Using a makefile with your Go project

By default, Shippable detects your project type, and uses the language’s standard means of installing dependencies and building your project. In Go for example, dependencies are typically obtained via the ‘go get’ command, and the project is built with the ‘go build’ command. Specifically, we use this command for your go projects.

 

shippable_retry go get -d -v ./... && go build -v ./...

Using Services with Custom Docker Images

As many of you might know, we provide a variety of images for your builds. By default, we use the image shippableImages/minv2 for all builds. This image comes preinstalled with many versions of all our supported languages, along with many popular services like Redis, MySQL, Elasticsearch, Postgres, etc.

However, many customers like using lightweight containers which only contain what they really need for their code. To address their scenarios, we have created some basic language specific images that can be found on our docker hub repo. There are images for the latest languages such as Scala, Clojure, and go, as well as for classics like Java and PHP on Ubuntu 12.04 and 14.04. The corresponding Dockerfiles for the images are in GitHub in the shippableImages org.  

Today, we'll learn how to use services on these custom images.

Custom Elasticsearch Configs and Shippable

Elastic search is a popular open source solution for querying text. While built on top of the JVM, elasticsearch provides APIs for a variety of programming languages. Shippable currently provides support for elastic search as a pre-installed service. The elasticsearch service can be enabled with a simple addition to your shippable.yml file:

services:
    - elasticsearch

For the uninitiated, additional info on Shippable services can be found here: services

If you desire a default elasticsearch configuration, the elasticsearch service is a great way to get up and running. However, we know many developers have specific configuration needs for elasticsearch, and Shippable wants you to know that we support custom configurations as well! All you need to do is provide your elasticsearch.yml file and change a few lines in your shippable.yml file.