include:
  - local: '/ci/yocto-ktn-common.yml'

stages:
  - build

# Build the docs and deploy them via GitLab Pages
pages:
  extends: .build-docs

# Build the Docker images and push them to the registry
build-docker:
  tags:
    - server
  stage: build
  image: docker:19.03.12
  services:
    - docker:19.03.12-dind
  script:
    - echo $CI_REGISTRY_USER
    - echo $CI_REGISTRY_PASSWORD
    - echo $CI_REGISTRY
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - docker pull $CI_REGISTRY_IMAGE:16 || true
    - docker build --cache-from $CI_REGISTRY_IMAGE:16 -t $CI_REGISTRY_IMAGE:16 -f Dockerfile.16 .
    - docker push $CI_REGISTRY_IMAGE:16
    - docker pull $CI_REGISTRY_IMAGE:20 || true
    - docker build --cache-from $CI_REGISTRY_IMAGE:20 -t $CI_REGISTRY_IMAGE:20 -f Dockerfile.20 .
    - docker push $CI_REGISTRY_IMAGE:20
