machine:
  python:
    version: 3.4.2
  services:
    - docker
  environment:
    DOCKER_PROJECT: fda-sandbox-web
    ORG: stsilabs
    EB_ENV: fda-sandbox

dependencies:
  pre:
    # build docker image
    - docker info
    - docker build -t $ORG/$DOCKER_PROJECT:$CIRCLE_BUILD_NUM .:
        timeout: 1800
    # install aws command line tools for elasticbean stalk deployment
    - pip install awscli
    # python setup
    - cd gruve && python setup.py develop

  post:
    # load .env from s3
    - aws s3 cp s3://open-fda/.env .env
    - bundle exec rake bower:install

test:
  override:
   - bundle exec rspec -t smoke
   - bundle exec rake teaspoon
   - cd gruve && python setup.py test

deployment:
  elasticbeanstalk:
    branch: master
    commands:
    # push docker image
    - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD
    - docker push $ORG/$DOCKER_PROJECT:$BUILD_TAG
    # deploy to AWS elastic beanstalk environment
    - bash aws_deploy.sh $CIRCLE_BUILD_NUM $DOCKER_PROJECT $ORG $EB_ENV:
        timeout: 1800
machine:
  python:
    version: 3.4.2
  services:
    - docker
  environment:
    DOCKER_PROJECT: fda-sandbox-web
    ORG: stsilabs
    EB_ENV: fda-sandbox

dependencies:
  cache_directories:
    - "~/docker"
  pre:
    # load docker image from cache
   - if [[ -e ~/docker/image.tar ]]; then docker load -i ~/docker/image.tar; fi
    # build docker image
    - docker info
    - docker build -t $ORG/$DOCKER_PROJECT:$CIRCLE_BUILD_NUM .:
        timeout: 1800
    # cache docker image
    - mkdir -p ~/docker; docker save $ORG/$DOCKER_PROJECT > ~/docker/image.tar
    # install aws command line tools for elasticbean stalk deployment
    - pip install awscli
    # python setup
    - cd gruve && python setup.py develop
  post:
    # load .env from s3
    - aws s3 cp s3://open-fda/.env .env
    - bundle exec rake bower:install

test:
  override:
   - bundle exec rspec -t smoke
   - bundle exec rake teaspoon
   - cd gruve && python setup.py test

deployment:
  elasticbeanstalk:
    branch: master
    commands:
    # push docker image
    - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD
    - docker push $ORG/$DOCKER_PROJECT:$BUILD_TAG
    # deploy to AWS elastic beanstalk environment
    - bash aws_deploy.sh $CIRCLE_BUILD_NUM $DOCKER_PROJECT $ORG $EB_ENV:
        timeout: 1800
Use cached docker image during builds
Use cached docker image during builds
