Skip to main content
U.S. flag

An official website of the United States government

The .gov means it’s official.
Federal government websites often end in .gov or .mil. Before sharing sensitive information, make sure you’re on a federal government site.

The site is secure.
The https:// ensures that you are connecting to the official website and that any information you provide is encrypted and transmitted securely.

Continuous deployment

Pre-requisites

This guide assumes that you already have:

1. Getting deployer credentials

Use the instructions on Cloud.gov to create a deployer account for your app. Your deployer credentials will regularly expire, so please make sure to update them periodically.

2. Configure the continuous integration service

Circle CI

Add your cloud.gov deployer service credentials as environment variables to CircleCI. Save them as the CF_USERNAME and CF_PASSWORD.

Update .circleci/config.yml

version: 2.1

jobs:
  test:
    # Your test configuration goes here.
    # Ruby - https://circleci.com/docs/2.0/language-ruby/
    # Python - https://circleci.com/docs/2.0/language-python/
    # JS - https://circleci.com/docs/2.0/language-javascript/

  deploy:
    docker:
      # This image has the latest cf-cli as well as zero downtime plugins, if needed.
      - image: governmentpaas/cf-cli:latest

    steps:
      - checkout
      - run:
          name: deploy to cloud.gov
          command: |
            # Set $CF_USERNAME and $CF_PASSWORD in CircleCI settings.
            # $CF_ORG, $CF_SPACE, and $APP_NAME can also be set in CircleCI settings or hardcoded here.
            cf api https://api.fr.cloud.gov
            cf auth "$CF_USERNAME" "$CF_PASSWORD"
            cf target -o "$CF_ORG" -s "$CF_SPACE"
            cf zero-downtime-push "$APP_NAME" -p '.' -f path/to/manifest.yml

workflows:
  test:
    jobs:
      - test:
          filters:
            branches:
              ignore: master
  deploy:
    jobs:
      - test:
          filters:
            branches:
              only: master
      - deploy:
          requires:
            - test
          filters:
            branches:
              only: master

Done!

Add manifests

Cloud.gov (and Cloud Foundry) use manifest files to specify how an app should be built on cloud.gov. You will now add two separate files, a manifest.yml for your production app and a manifest-staging.yml for your development application.

Generally your production application will have multiple instances while your staging will only have one. Manifests can be short and sweet, or extensive. See the full cloud foundry documentation on manifests.

For an example manifest and manifest-staging see:

Zero downtime deploy options

  • Standard The native Cloud Foundry rolling app deployments CLI is preferred over other options.
  • Caution Autopilot is a plugin historically used by a lot of 18F projects and used in both of the above examples. It is now unmaintained and archived and does not support buildpacks. We recommend moving to the official CF deployment commands.
    • If you are using autopilot and your application successfully deploys to cloud.gov but does not start, which may happen for an application that does not have an adequate test suite, you may have to go into the cf target space and manually delete the "APP_NAME-venerable" application in order to make use of autopilot again.
  • blue-green-deploy another plugin similar to autopilot.
  • See an official CircleCI / Cloud Foundry Orb

18F Engineering

An official website of the GSA’s Technology Transformation Services

Looking for U.S. government information and services?
Visit USA.gov