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:
  stage: build
  parallel:
    matrix:
      - PHP: ['7.0','7.1','7.2','7.3','7.4','8.0','8.1']
  script:
    - docker build --pull --build-arg PHP_VERSION=${PHP} --build-arg VERSION=${VERSION} -t ${CI_REGISTRY_IMAGE}/php-${PHP}:${VERSION} .
    - docker push ${CI_REGISTRY_IMAGE}/php-${PHP}:${VERSION}
  only:
    - tags