variables:
  VERSION: ${CI_COMMIT_TAG}

before_script:
  - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY

setup:
  stage: build
  script:
    - docker build --pull --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/setup:${VERSION} ./setup
    - docker build --pull --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/setup:latest ./setup
    - docker push ${CI_REGISTRY_IMAGE}/setup:${VERSION}
    - docker push ${CI_REGISTRY_IMAGE}/setup:latest
  only:
    - tags

run:
  stage: build
  script:
    - docker build --pull --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/run:${VERSION} ./run
    - docker push ${CI_REGISTRY_IMAGE}/run:${VERSION}
  only:
    - tags

php-7.0:
  stage: build
  script:
    - docker build --pull --build-arg PHP_VERSION=7.0 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.0:${VERSION} .
    - docker push ${CI_REGISTRY_IMAGE}/php-7.0:${VERSION}
  only:
    - tags

php-7.1:
  stage: build
  script:
    - docker build --pull --build-arg PHP_VERSION=7.1 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.1:${VERSION} .
    - docker push ${CI_REGISTRY_IMAGE}/php-7.1:${VERSION}
  only:
    - tags

php-7.2:
  stage: build
  script:
    - docker build --pull --build-arg PHP_VERSION=7.2 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.2:${VERSION} .
    - docker push ${CI_REGISTRY_IMAGE}/php-7.2:${VERSION}
  only:
    - tags

php-7.3:
  stage: build
  script:
    - docker build --pull --build-arg PHP_VERSION=7.3 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.3:${VERSION} .
    - docker push ${CI_REGISTRY_IMAGE}/php-7.3:${VERSION}
  only:
    - tags

php-7.4:
  stage: build
  script:
    - docker build --pull --build-arg PHP_VERSION=7.4 --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-7.4:${VERSION} .
    - docker push ${CI_REGISTRY_IMAGE}/php-7.4:${VERSION}
  only:
    - tags
