version: 2
jobs:
  test:
    docker:
      - image: rust:latest
    steps:
      - checkout
      - run: cargo test

  build:
    docker:
      - image: rust:latest
    steps:
      - checkout
      - run: cargo build --release
      - run: echo $CIRCLE_SHA1 > .circle-sha
      - save_cache:
          key: build-{{ .Branch }}-{{ checksum ".circle-sha" }}
          paths:
            - ~/project/.deploy
            - ~/project/target/release

  build_container:
    docker:
      - image: docker:latest
    steps:
      - run: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          key: build-{{ .Branch }}-{{ checksum ".circle-sha" }}
      - setup_remote_docker
      - run:
          command: |
            cp target/release/mm_api_notify .deploy/mm_api_notify
            cd .deploy
            docker build -t mm_api_notify .
            docker tag mm_api_notify:latest tptwebmaster/mm_api_notify:latest
            docker login -u $DOCKER_USER -p $DOCKER_PASS
            docker push tptwebmaster/mm_api_notify:latest

workflows:
  version: 2
  build:
    jobs:
      - test
      - build:
          requires:
            - test
      - build_container:
          requires:
            - build
          filters:
            branches:
              only:
                - master
version: 2
jobs:
  test:
    docker:
      - image: tptwebmaster/rust-centos:latest
    steps:
      - checkout
      - run: cargo test

  build:
    docker:
      - image: tptwebmaster/rust-centos:latest
    steps:
      - checkout
      - run: cargo build --release
      - run: echo $CIRCLE_SHA1 > .circle-sha
      - save_cache:
          key: build-{{ .Branch }}-{{ checksum ".circle-sha" }}
          paths:
            - ~/project/.deploy
            - ~/project/target/release

  build_container:
    docker:
      - image: docker:latest
    steps:
      - run: echo $CIRCLE_SHA1 > .circle-sha
      - restore_cache:
          key: build-{{ .Branch }}-{{ checksum ".circle-sha" }}
      - setup_remote_docker
      - run:
          command: |
            cp target/release/mm_api_notify .deploy/mm_api_notify
            cd .deploy
            docker build -t mm_api_notify .
            docker tag mm_api_notify:latest tptwebmaster/mm_api_notify:latest
            docker login -u $DOCKER_USER -p $DOCKER_PASS
            docker push tptwebmaster/mm_api_notify:latest

workflows:
  version: 2
  build:
    jobs:
      - test
      - build:
          requires:
            - test
      - build_container:
          requires:
            - build
          filters:
            branches:
              only:
                - master
Switch to custom rust build
Switch to custom rust build
