machine:
  services:
    - docker

dependencies:
  override:
    - docker build -t test-integration-dockerfile:latest .
    - >
      docker run
      -e "APIKEY=${APIKEY}"
      -e "CIRCLE_PROJECT_REPONAME=${CIRCLE_PROJECT_REPONAME}"
      -e "CIRCLE_BUILD_NUM=${CIRCLE_BUILD_NUM}"
      -e "IMAGE=${IMAGE:-coreos-beta}"
      --name=test-integration-dockerfile-init test-integration-dockerfile:latest /initialize.sh
    - docker commit test-integration-dockerfile-init test-integration-dockerfile:latest

test:
  override:
    - docker run --name=test-integration-dockerfile test-integration-dockerfile:latest /run_tests.sh
  post:
    - docker run --name=DUMP-test-integration-dockerfile test-integration-dockerfile:latest vagrant ssh -- sudo journalctl
    - docker run --name=DESTROY-test-integration-dockerfile test-integration-dockerfile:latest vagrant destroy -f
    # TODO: Collect container as an asset?


machine:
  services:
    - docker

dependencies:
  override:
    - docker build -t test-integration-dockerfile:latest .
    - >
      docker run
      -e "APIKEY=${APIKEY}"
      -e "CIRCLE_PROJECT_REPONAME=${CIRCLE_PROJECT_REPONAME}"
      -e "CIRCLE_BUILD_NUM=${CIRCLE_BUILD_NUM}"
      -e "IMAGE=${IMAGE:-coreos-beta}"
      --name=test-integration-dockerfile-init test-integration-dockerfile:latest /initialize.sh
    - docker commit test-integration-dockerfile-init test-integration-dockerfile:latest

test:
  override:
    - docker run --name=test-integration-dockerfile test-integration-dockerfile:latest /run_tests.sh
  post:
    - docker run test-integration-dockerfile:latest ssh-keygen -l -f /.ssh/id_rsa | awk '{ print $2 }' > ~/sshid
    - docker run --name=DUMP-test-integration-dockerfile test-integration-dockerfile:latest vagrant ssh -- sudo journalctl
    - docker run --name=DESTROY-test-integration-dockerfile test-integration-dockerfile:latest vagrant destroy -f
    - 'curl -f -X DELETE -H "Content-Type: application/json" -H "Authorization: Bearer ${APIKEY}" https://api.digitalocean.com/v2/account/keys/$(cat ~/sshid)'
    # TODO: Collect container as an asset?

Remove SSH Key from Digital Oceans key ring after the test machine was destroyed.
Remove SSH Key from Digital Oceans key ring after the test machine was destroyed.
