stages:
- build_image
#- test

variables:
  DEPENDENCIES_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/image:latest"
  MYDOCKER_IMAGE_NAME: "${CI_REGISTRY_IMAGE}/mydocker-image:latest"
  STORAGE_DRIVER: vfs # for buildah
  REGISTRY_AUTH_FILE: /root/auth.json

build_image:
  stage: build_image
  image: tomkukral/buildah:0.32
  before_script:
    - podman login --username "${CI_REGISTRY_USER}" --password "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
  script:
    - buildah build-using-dockerfile --format docker -t ${DEPENDENCIES_IMAGE_NAME} --file Dockerfile-CI .
    - buildah push --authfile ${REGISTRY_AUTH_FILE} ${DEPENDENCIES_IMAGE_NAME}
    - buildah build-using-dockerfile --pull-never --format docker -t ${MYDOCKER_IMAGE_NAME} --file Dockerfile-myDocker-CI .
    - buildah push --authfile ${REGISTRY_AUTH_FILE} ${MYDOCKER_IMAGE_NAME}
  after_script:
    - podman logout "${CI_REGISTRY}"
#  only:
#    changes:

image: ${DEPENDENCIES_IMAGE_NAME}

# test:
#     stage: test
#     script:
#       - mypy
