variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_DRIVER: overlay2
    CONTAINER_TEST_IMAGE: docker.km3net.de/simulation/km3buu:$CI_COMMIT_REF_SLUG
    CONTAINER_RELEASE_IMAGE: docker.km3net.de/simulation/km3buu:$CI_COMMIT_TAG
    CONTAINER_LATEST_IMAGE: docker.km3net.de/simulation/km3buu:latest

stages:
    - docker
    - release

docker:
   image: docker:stable
   services:
     - docker:dind
   stage: docker
   script:
     - docker build --pull -t $CONTAINER_TEST_IMAGE .
     - docker push $CONTAINER_TEST_IMAGE
   tags:
     - docker
   only:
     - tags

release-image:
   image: docker:stable
   services:
     - docker:dind
   stage: release
   script:
     - docker pull $CONTAINER_TEST_IMAGE
     - docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
     - docker tag $CONTAINER_TEST_IMAGE $CONTAINER_LATEST_IMAGE
     - docker push $CONTAINER_RELEASE_IMAGE
     - docker push $CONTAINER_LATEST_IMAGE
   tags:
     - docker
   only:
     - tags

