machine:
  environment:
    DOCKER_IMAGE: miriamtech/passenger-base
  timezone: America/Los_Angeles
  services:
    - docker

dependencies:
  cache_directories:
    - "~/docker"
  override:
    - build/touch_git_commit scripts
    - if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
    - docker build -t $DOCKER_IMAGE .
    - mkdir -p ~/docker; docker save $DOCKER_IMAGE:latest > ~/docker/image.tar

test:
  override:
    - docker run $DOCKER_IMAGE:latest /sbin/my_init -- echo "Success"

deployment:
  hub:
    branch: master
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
      - docker tag $DOCKER_IMAGE:latest $DOCKER_IMAGE:${CIRCLE_SHA1:0:6}
      - docker push $DOCKER_IMAGE

machine:
  environment:
    DOCKER_IMAGE: miriamtech/passenger-base
  timezone: America/Los_Angeles
  services:
    - docker

dependencies:
  cache_directories:
    - "~/docker"
  override:
    - build/touch_git_commit scripts
    - if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
    - docker build -t $DOCKER_IMAGE .
    - mkdir -p ~/docker; docker save $DOCKER_IMAGE:latest > ~/docker/image.tar

test:
  override:
    - docker run $DOCKER_IMAGE:latest /sbin/my_init -- echo "Success"

deployment:
  hub:
    branch: master
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
      - docker tag $DOCKER_IMAGE:latest $DOCKER_IMAGE:${CIRCLE_SHA1:0:7}
      - docker push $DOCKER_IMAGE

Tag with first 7 characters of commit SHA1
Tag with first 7 characters of commit SHA1
