stages:
  - Build

"Build Docker":
  stage: Build
  image: docker:24.0.5

  before_script:
    - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
  script:
    - echo "Building Docker-image..."

    - >
      docker build 
      --label "org.opencontainers.image.url=$CI_PROJECT_URL" 
      --label "org.opencontainers.image.source=$CI_PROJECT_URL"
      -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG 
      -t $CI_REGISTRY_IMAGE:latest .
    
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
    - docker push $CI_REGISTRY_IMAGE:latest

  rules:
    - if: $CI_COMMIT_TAG
