# This is a sample build configuration for Docker.
# Check our guides at https://confluence.atlassian.com/x/O1toN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
# image: atlassian/default-image:latest

# enable Docker for your repository
options:
  docker: true

image: kdanmobile/10.14.2:latest


pipelines:
  branches:
    master:
      - step:
          script:
            - yarn install
            - yarn test
            - NODE_ENV=production ENV=production yarn build
            - docker build -t ${AWS_REGISTRY_URL}/pdf-reader-web:production --build-arg BRANCH=$BITBUCKET_BRANCH --build-arg COMMIT=$BITBUCKET_COMMIT --build-arg ENV=production .
            - eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
            - docker push ${AWS_REGISTRY_URL}/pdf-reader-web:production
    develop:
      - step:
          script:
            - yarn install
            # - yarn test
            - NODE_ENV=production ENV=preparing yarn build
            - docker build -t ${AWS_REGISTRY_URL}/pdf-reader-web:preparing --build-arg BRANCH=$BITBUCKET_BRANCH --build-arg COMMIT=$BITBUCKET_COMMIT --build-arg ENV=preparing .
            - eval $(aws ecr get-login --region ${AWS_DEFAULT_REGION} --no-include-email)
            - docker push ${AWS_REGISTRY_URL}/pdf-reader-web:preparing
