CircleCI

Consider the following three stage integration pipeline.

  • Stage 1. Build and publish of Docker images
  • Stage 2. Deployment to test cloud
  • Stage 3. Deployment to production cloud

There are only three key commands:

  1. berlioz push: Builds all docker images within the code base and publishes images to container image repository.
  2. berlioz run: Performs deployment to specified environment(test, prod, etc.) and cloud region. The command would setup the infrastructure along with databases, storage, message queues, services, cloud functions, Kubernetes & Istio configs, etc.
  3. berlioz stop: Terminates the deployment. Very useful to tear down the test environment and wipe out resources.

A sample of CircleCI configuration:

version: 2
jobs:
  push_images:
    docker:
      - image: circleci/openjdk:8-jdk-node
    steps:
      - setup_remote_docker
      - run:
          name: Berlioz Setup
          command: curl -sL https://raw.githubusercontent.com/berlioz-the/berlioz/master/support/setup | sudo -E bash -
      - checkout
      - run: 
          name: Berlioz Setup Workspace
          command: mkdir -p berlioz_workspace
      - run: 
          name: Berlioz Login
          command: berlioz login --user $BERLIOZ_USER --pass $BERLIOZ_PASS
      - run: 
          name: Berlioz Build and Push Images
          command: sudo -E bash -c 'berlioz push --region $REGION --version-metadata-path berlioz_workspace/version-metadata'
      - persist_to_workspace:
          root: .
          paths:
              - berlioz_workspace

  test_deploy:
    docker:
      - image: berliozcloud/circleci-cli
    steps:
      - attach_workspace:
          at: .
      - run: 
          name: Berlioz Login
          command: berlioz login --user $BERLIOZ_USER --pass $BERLIOZ_PASS
      - run: 
          name: Berlioz Deploy to Test Cloud
          command: berlioz run --deployment test --cluster myapp --region $REGION --version-metadata-path berlioz_workspace/version-metadata --wait --timeout 900
      - run: 
          name: Smoke Tests
          command: echo "Here we would run our smoke tests to make sure things work in test cloud"
      - run: 
          name: Berlioz Trigger Stop
          command: berlioz stop --deployment test --cluster myapp --region $REGION

  prod_deploy:
    docker:
      - image: berliozcloud/circleci-cli
    steps:
      - attach_workspace:
          at: .
      - run: 
          name: Berlioz Login
          command: berlioz login --user $BERLIOZ_USER --pass $BERLIOZ_PASS
      - run: 
          name: Berlioz Deploy
          command: berlioz run --deployment prod --cluster myapp --region $REGION --version-metadata-path berlioz_workspace/version-metadata --wait --timeout 900

workflows:
  version: 2
  deliver:
    jobs:
      - push_images
      - test_deploy:
          requires:
            - push_images
      - prod_deploy:
          requires:
            - push_images
            - test_deploy