Continuous Integration

Part 2, Chapter 3

Next, we'll add continuous integration (CI), via Travis CI, to our projects.

Do you usually use a different CI service or run Jenkins? It's encouraged to check your understanding by continuing to use the CI service that you're accustomed to. Convert the Travis configuration examples as necessary.

Follow steps 1 and 2 of the Getting Started guide to enable Travis in the project.

To trigger a build, add a .travis.yml file to the project root:

sudo: required

  - docker


  - sudo rm /usr/local/bin/docker-compose
  - curl -L${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
  - chmod +x docker-compose
  - sudo mv docker-compose /usr/local/bin

  - docker-compose up -d --build

  - docker-compose exec users python test
  - docker-compose exec users flake8 project

  - docker-compose down

Commit your changes, and then push to GitHub. This should trigger a new build, which should pass.

If you get an error indicating that port 5432 is already used -- Failed to bind tcp address already in use -- make sure that port is only exposed to other containers in the Docker Compose file. It should not be exposed to the host.

Once done, add a file to the project root, adding the Travis status badge:

# Microservices with Docker, Flask, and React

[![Build Status](](

Be sure to replace YOUR_GITHUB_USERNAME with your actual GitHub username.

In terms of workflow, for now, while the project structure is still somewhat simple, we'll:

  1. Code a new feature locally
  2. Commit and push code
  3. Ensure tests pass on Travis

Mark as Completed