machine:
  environment:
    TAG: ${CIRCLE_SHA1:0:7}
  services:
    - docker

dependencies:
  override:
    - docker build -t craftship/phonebox-api:$TAG ./src/api
    - docker build -t craftship/phonebox-workers:$TAG ./src/workers

test:
  override:
    - docker run -d -p 80:8080 craftship/phonebox-api:$TAG; sleep 3
    - curl --retry 3 --retry-delay 1 -v http://localhost

deployment:
  hub:
    branch: master
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD
      - docker push craftship/phonebox-api:$TAG
      - docker push craftship/phonebox-workers:$TAG

machine:
  environment:
    TAG: latest
  services:
    - docker

dependencies:
  override:
    - docker build -t craftship/phonebox-api:$TAG ./src/api
    - docker build -t craftship/phonebox-workers:$TAG ./src/workers

test:
  override:
    - docker run -d -p 80:8080 craftship/phonebox-api:$TAG; sleep 3
    - curl --retry 3 --retry-delay 1 -v http://localhost

deployment:
  hub:
    branch: master
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD
      - docker push craftship/phonebox-api:$TAG
      - docker push craftship/phonebox-workers:$TAG

Use latest tag instead when building on master
Use latest tag instead when building on master

Allows consistency when people use deploy to Docker Cloud button in README
