image: docker:stable

variables:
  IMAGE_NAME: emcmongoose/darzee
  IMAGE_TAG: ${DARZEE_VER}

stages:
  - build_docker_image
  - deploy

build_docker_image:
  stage: build_docker_image
  script:
    - ./gradlew clean buildImage

release_to_docker_hub:
  stage: deploy
  script:
    - docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
    - docker load < ${IMAGE_FILE_NAME}
    - docker tag ${IMAGE_NAME}:${CI_COMMIT_SHA} ${IMAGE_NAME}:${MONGOOSE_VERSION}
    - docker push ${IMAGE_NAME}:${IMAGE_TAG}
    - docker tag ${IMAGE_NAME}:${IMAGE_TAG}
    - docker push ${IMAGE_NAME}:${IMAGE_TAG}

  only:
    - latest
  except:
    - branches
image: java:8-jdk

variables:
  IMAGE_NAME: emcmongoose/darzee
  IMAGE_TAG: ${DARZEE_VER}

before_script:
#  - echo `pwd` # debug
#  - echo "$CI_BUILD_NAME, $CI_BUILD_REF_NAME $CI_BUILD_STAGE" # debug
  - export GRADLE_USER_HOME=`pwd`/.gradle

cache:
paths:
    - .gradle/wrapper
    - .gradle/caches

stages:
  - build_docker_image
  - deploy

build_docker_image:
  stage: build_docker_image
  script:
    - ./gradlew clean buildImage

release_to_docker_hub:
  stage: deploy
  script:
    - docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
    - docker load < ${IMAGE_FILE_NAME}
    - docker tag ${IMAGE_NAME}:${CI_COMMIT_SHA} ${IMAGE_NAME}:${MONGOOSE_VERSION}
    - docker push ${IMAGE_NAME}:${IMAGE_TAG}
    - docker tag ${IMAGE_NAME}:${IMAGE_TAG}
    - docker push ${IMAGE_NAME}:${IMAGE_TAG}

  only:
  # NOTE: Using GUI-47-continious-integration in test purposes 
    - GUI-47-continious-integration
  except:
    - branches
Change base image of the CI instance.
Change base image of the CI instance.
