machine:
  node:
    version: 4.3.0
  services:
    - docker

dependencies:
  pre:
    - echo $BUILD_TAG
    - docker build -t constellates/$CIRCLE_PROJECT_REPONAME:$([ "$CIRCLE_BRANCH" == circle-ci ] && echo "dev-" || echo "")$(node -p -e "require('./package.json').version") .

test:
  override:
    # Lint
    - docker run constellates/$CIRCLE_PROJECT_REPONAME:$([ "$CIRCLE_BRANCH" == circle-ci ] && echo "dev-" || echo "")$(node -p -e "require('./package.json').version") npm run lint
    # Unit Tests
    - docker run constellates/$CIRCLE_PROJECT_REPONAME:$([ "$CIRCLE_BRANCH" == circle-ci ] && echo "dev-" || echo "")$(node -p -e "require('./package.json').version") npm run test

deployment:
  hub:
    branch: circle-ci
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
      - docker tag constellates/$CIRCLE_PROJECT_REPONAME constellates/$CIRCLE_PROJECT_REPONAME:$([ "$CIRCLE_BRANCH" == circle-ci ] && echo "dev-" || echo "")latest
      - docker push constellates/$CIRCLE_PROJECT_REPONAME
machine:
  node:
    version: 4.3.0
  services:
    - docker
  enviroment
    BRANCH_TAG: $([ "$CIRCLE_BRANCH" == circle-ci ] && echo "dev-" || echo "")

dependencies:
  pre:
    - echo $BRANCH_TAG
    - docker build -t constellates/$CIRCLE_PROJECT_REPONAME:$BRANCH_TAG$(node -p -e "require('./package.json').version") .

test:
  override:
    # Lint
    - docker run constellates/$CIRCLE_PROJECT_REPONAME:$BRANCH_TAG$(node -p -e "require('./package.json').version") npm run lint
    # Unit Tests
    - docker run constellates/$CIRCLE_PROJECT_REPONAME:$BRANCH_TAG$(node -p -e "require('./package.json').version") npm run test

deployment:
  hub:
    branch: circle-ci
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
      # - docker tag constellates/$CIRCLE_PROJECT_REPONAME constellates/$CIRCLE_PROJECT_REPONAME:${BRANCH_TAG}latest
      - docker push constellates/$CIRCLE_PROJECT_REPONAME
Test branch tag env variable
Test branch tag env variable
