Skip to content

Instantly share code, notes, and snippets.

@johnallen3d
Last active February 7, 2018 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnallen3d/69fcaf3766888be36ebd277951221c82 to your computer and use it in GitHub Desktop.
Save johnallen3d/69fcaf3766888be36ebd277951221c82 to your computer and use it in GitHub Desktop.

Continuous Integration (CI) and
Continuous Delivery (CD)

Background reading

ci-cd-illustration

CI

Regular automated builds and testing of a code base. We are using CircleCI to facilitate CI (and sometimes CD, see Container Runtime).

GitHub -> CircleCI -> CodeClimate
       \> CodeClimate

Setup

Setup documentation

Configuration

Example configuration

Container

CircleCI v2.0 runs inside of Docker image/container of your choosing. We have authored an image (technekes/circleci:latest) that includes Docker Compose allowing for us to run specs in a manner very similar to our development environment.

  • docker-compose
  • Danger
  • nib-crypt (future)

Test Coverage

Test coverage can be captured by simplecov while running specs and reported to CodeClimate for integrations with a repos analysis. Additionally the simplecov output can be stored as a build artifact CircleCI (example).

CD

Delivering every successful build to staging to allow for acceptance testing. This is not Continuous Deployment which would be delivering each successful build into production.

GitHub -> CircleCI -> Heroku (staging)

Automatic Deploys

A Heroku app can be configured to deploy automatically when code is pushed to a specified branch and CI passes.

Preboot

Heroku apps can be configured for zero downtime deployments by enabling preboot. Preboot will deploy new code to a new Dyno, ensure the application boots successfully, and wait for 3 minutes before pointing the load balancer at the new dyno(s).

Deployment Notifications

Apps on Heroku can deliver deployment notifications to a URL. We use this feature along with Rollbar to track deployments and trigger notifications from Rollbar into Slack.

Logs

Heroku application and addon logs can be accessed via the Heroku CLI.

# follow the logs of Fluxer staging
heroku logs -t -a tk-stage-fluxer
# or from a directory named `tk-fluxer`
nib logs -f -e stage
# or if the app uses papertrail
heroku addons:open papertrail -a abc-stage-web-app

Common Runtime vs Container Runtime

The traditional git push deployment on Heroku takes advantage of the Common Runtime. Recently Heroku has added support for running arbitrary Docker container via the Container Runtime (docker push).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment