Skip to main content

Deploying Federalist

Deploying Federalist from TravisCI

This guide covers how the deployment process for Federalist and Federalist Builder works. In order to understand the process for Federalist Docker Build and Federalist Registry, see the cloud.gov setup guide.

Federalist is deployed by TravisCI. Federalist and Federalist Builder are configured such that changes to the master branch are deployed to production and changes to the staging branch are deployed to staging. In both repos this configuration lives in the .travis.yml file in the project root.

Both projects use a file at scripts/deploy-travis.sh to run the actual deploy. These scripts authenticate with cloud.gov using a cloud.gov deploy user. Despite some minor differences, both of these scripts do essentially the same thing:

  1. Check the current branch and use it to determine which space to deploy to
  2. Install Autopilot for cf-cli (used for zero downtime deploys)
  3. Use cf login to authenticate the deploy user
  4. Do a zero downtime push of the application

It is worth noting that the environment for these scripts is set in the .travis.yml for the following:

Zero downtime deploys

Federalist has high availability requirements because it needs to be up to receive GitHub webhook and build status requests. Because of this, the autopilot Cloud Foundry CLI plugin is used so the app can be deployed without downtime.

Zero downtime deploys work by:

  1. Renaming the app to <appname>-venerable, for example federalist-venerable
  2. Pushing a new app with the old app's name
  3. When the new app is started, routing requests to the new app and deleting the venerable app

Cleanup after a failed deploy

If autopilot fails to deploy the new app, it exits and does not clean up after itself. So after a failed deploy there will be a stopped app named <appname> and a running app named <appname>-venerable fielding requests. This is by design so that a failed deploy does not cause the app to go down.

The downside of this setup is that all future deploys will fail since there will be a name collision on <appname>-venerable. As a result, the failed deploy will need to be cleaned up before another deploy can succeed.

To cleanup after a failed deploy:

  1. Delete the new app. For the main Federalist app that would be federalist.
  2. Rename the venerable app to the name of the new app. For example, rename federalist-venerable to federalist.
  3. Start a build on Travis to re-deploy.