image: atlassian/default-image:2

pipelines:
  default:
    - step:
        max-time: 30
        services:
          - docker
        script:
          - export DOCKER_IMAGE_NAME=mjanssen2308/casavlbi
          - export DOCKER_EHTPRODEXT=ehtproduction
          - docker build -f dockerfiles/default/Dockerfile -t ${DOCKER_IMAGE_NAME}:latest -t ${DOCKER_IMAGE_NAME}:${BITBUCKET_COMMIT} .
          - docker build -f dockerfiles/${DOCKER_EHTPRODEXT}/Dockerfile -t ${DOCKER_IMAGE_NAME}_${DOCKER_EHTPRODEXT}:${BITBUCKET_COMMIT}_$(git ls-remote https://bitbucket.org/M_Janssen/casaeht HEAD | awk '{ print $1}') .
          - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD
          - docker push ${DOCKER_IMAGE_NAME}
          - docker push ${DOCKER_IMAGE_NAME}_${DOCKER_EHTPRODEXT}
