stages:
  - build image
  - test image
  - build chart
  - deploy
#  - registry_cleanup
image: docker:19.03.1
variables:
  DOCKER_TLS_CERTDIR: ""
  DOCKER_HOST: "tcp://localhost:2375"
#  DOCKER_TLS_CERTDIR: "/certs"
#  DOCKER_HOST: "tcp://localhost:2376"
  DOCKER_DRIVER: overlay2
  HELM_EXPERIMENTAL_OCI: "1"
services:
  - docker:19.03.1-dind

include:
  - project: 'cspp_geo/geosphere/geosphere-deploy'
    file: '/helpers/docker_base.yaml'
  - project: 'cspp_geo/geosphere/geosphere-deploy'
    file: '/helpers/build_image.yaml'
  - project: 'cspp_geo/geosphere/geosphere-deploy'
    file: '/helpers/helm_base.yaml'
  - project: 'cspp_geo/geosphere/geosphere-deploy'
    file: '/helpers/build_chart.yaml'

build_image_mapserver:
  extends: .build_image
  variables:
    IMAGE_NAME: "geosphere-mapserver"
    IMAGE_DIR: "mapserver"
    TEST_SCRIPTS: "ci/test_mapserver_image.sh"

build_chart:
  extends: .build_chart
  variables:
    CHART_NAME: "geosphere-mapserver"

deploy_application:
  stage: deploy
  trigger:
    project: cspp_geo/geosphere/geosphere-deploy
    strategy: depend
  when: manual


#registry_cleanup:
#  stage: registry_cleanup
#  tags:
#    - docker
#  script:
#    - ci/registry_cleanup.sh
