Skip to main content
U.S. flag

An official website of the United States government

Dot gov

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.

Https

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. For the full cloud foundry documentation on manifests see here: https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html#minimal-manifest.

For an example manifest and manifest-staging see here: Acquisitions Manifest Acquisitions Manifest-Staging

Zero Downtime Deploy Options