image: java:8-jdk

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:
  # NOTE: Using GUI-47-continious-integration in test purposes 
    - GUI-47-continious-integration
  except:
    - branches

variables:
  IMAGE_NAME: emcmongoose/darzee
  IMAGE_TAG: ${DARZEE_VER}
  IMAGE_FILE_NAME: build/darzee.tar

stages:
  - build
  - deploy

create_dockerfile:
  image: java:8-jdk
  stage: build
  script:
    - ./gradlew clean createDockerfile

build_docker_image:
  image: docker:stable
  stage: build
  script:
    - docker build -f ${CREATED_DARZEE_DOCKERFILE_PATH} -t ${IMAGE_NAME}:${IMAGE_TAG}
    - docker save ${IMAGE_NAME}:${CI_COMMIT_SHA} > ${IMAGE_FILE_NAME}
  artifacts:
    paths:
      - ${IMAGE_FILE_NAME}

release_to_docker_hub:
  image: docker:stable
  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
Add usage of different images in gitlab CI. Images are depended on the stage.
Add usage of different images in gitlab CI. Images are depended on the stage.
