version: 2
jobs:
  build:
    environment:
      - API_DOCKER_IMAGE=api-ci
      - JOB_DOCKER_IMAGE=job-ci
    docker:
      - image: docker:18.05.0-ce-git
      - image: slideroom/elasticsearch:98
        environment:
          - ES_JAVA_OPTS=-Xms750m -Xmx750m
    steps:
      - checkout
      - setup_remote_docker:
          docker_layer_caching: true
      - run:
          name: Integration Tests
          command: |
            docker build --target testrunner -t exceptionless:test .
            mkdir TestResults
            DOCKER_CID=$(docker run --network host exceptionless:test)
            docker cp $DOCKER_CID:/app/tests/Exceptionless.Tests/TestResults /TestResults
      - store_test_results:
          path: TestResults
      - run:
          name: Build jobs docker image
          command: docker build --target job -t $JOB_DOCKER_IMAGE .
      - run:
          name: Build API docker image
          command: docker build --target api -t $API_DOCKER_IMAGE .
      - deploy:
          name: Push docker images
          command: |
            if [ "${CIRCLE_BRANCH}" == "feature/aspnet21" ]; then
              BUILD_TAG="$BUILD_VERSION-$BUILD_SUFFIX"

              # Login to Docker
              echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin

              # Tag and push docker image
              for image in {$API_DOCKER_IMAGE,$JOB_DOCKER_IMAGE}; do  
                for tag in {$BUILD_TAG,latest}; do
                  (
                    docker tag $image exceptionless/$image:$tag
                    docker push exceptionless/$image:$tag
                  ) &
                done
              done
              wait
            fi

version: 2
jobs:
  build:
    machine:
      docker_layer_caching: true
    environment:
      - API_DOCKER_IMAGE=api-ci
      - JOB_DOCKER_IMAGE=job-ci
    steps:
      - checkout
      - run:
          name: Integration Tests
          command: |
            docker run -d -e ES_JAVA_OPTS="-Xms750m -Xmx750m" -p 9200:9200 slideroom/elasticsearch:98
            docker build --target testrunner -t exceptionless:test .
            mkdir TestResults
            docker run --network host -v $(pwd)/TestResults:/app/tests/Exceptionless.Tests/TestResults exceptionless:test
      - store_test_results:
          path: TestResults
      - run:
          name: Build jobs docker image
          command: docker build --target job -t $JOB_DOCKER_IMAGE .
      - run:
          name: Build API docker image
          command: docker build --target api -t $API_DOCKER_IMAGE .
      - deploy:
          name: Push docker images
          command: |
            if [ "${CIRCLE_BRANCH}" == "feature/aspnet21" ]; then
              BUILD_TAG="$BUILD_VERSION-$BUILD_SUFFIX"

              # Login to Docker
              echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin

              # Tag and push docker image
              for image in {$API_DOCKER_IMAGE,$JOB_DOCKER_IMAGE}; do  
                for tag in {$BUILD_TAG,latest}; do
                  (
                    docker tag $image exceptionless/$image:$tag
                    docker push exceptionless/$image:$tag
                  ) &
                done
              done
              wait
            fi

Change build to use machine image
Change build to use machine image
