Using Amazon EC2 Container Service (ECS) with Travis CI

Image for post
Image for post

If you are using Dockerwith Travis CIand you are not using some Docker registryto hold your pre-built images you will have to build the images on Travis with every build. Even for simple application stacks this can be a slow and expensive process. Ideally you want to move towards publishing your images to a registry.

A registry holds the images at different versions so they can be pulled down quickly, easily and contain an exact snapshot of what your application needs for that tag. A registry is similar to a Git repository where you have commits (this would be the image versions) and tags pointed to specific commits. The latesttag is kind of like the masterbranch.

There are several good Docker registries, one of which is Amazon EC2 Container Service, or ECS for short.

Wechose to use ECS because we use many other AWS products, so it just made sense. However, your needs may be different. This article is specially about how to use ECS with Travis.

Here is the important snippet for your Travis configuration:

before_install:
# Update docker-engine.
- sudo apt-get update
- sudo apt-get install -o Dpkg::Options::="--force-confold" --force-yes -y docker-engine

The AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY need to be filled in if they have not been set any other way (such as using encrypted environment variables). You will also may need to change the — region. It is best to create new keys just for Travis in case they need to be changed in the future.

Originally published at http://elliot.land on September 18, 2016.

Written by

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store