#!/bin/bash

set -eo pipefail

source "ci/_build_ci_image_common"

build() {
    echo "Building image: ${BUILD_IMAGE}"
    docker build \
           --cache-from "${BUILD_IMAGE}" \
           --build-arg DOCKER_VERSION="${DOCKER_VERSION}" \
           --build-arg BUILDX_VERSION="${BUILDX_VERSION}" \
           --build-arg PWSH_VERSION="${PWSH_VERSION}" \
           --build-arg GIT_LFS_VERSION="${GIT_LFS_VERSION}" \
           --build-arg GIT_LFS_AMD64_CHECKSUM="${GIT_LFS_LINUX_AMD64_CHECKSUM}" \
           --build-arg KUBECTL_VERSION="${KUBECTL_VERSION}" \
           --build-arg AWS_CLI_VERSION="${AWS_CLI_VERSION}" \
           --build-arg YQ_VERSION="${YQ_VERSION}" \
           -t "${BUILD_IMAGE}" \
           -f "${BUILD_DOCKERFILE}" \
           "${GIT_ROOT}"
}

login
pull
build
push
logout
scan
