#!/bin/bash
set -e

cd $(dirname $0)/..

. ./scripts/version.sh

if [ "${OS}" != "linux" ]; then
  exit
fi

TAG=${TAG:-${VERSION_TAG}${SUFFIX}}
REPO=${REPO:-rancher}
IMAGE_NAME=${IMAGE_NAME:-k3s}
PLATFORM=${PLATFORM:-${OS}/${ARCH}}

IMAGE=${REPO}/${IMAGE_NAME}:${TAG}
docker build --build-arg TAG=${VERSION_TAG} -t ${IMAGE} --platform ${PLATFORM} -f package/Dockerfile .
./scripts/image_scan.sh ${IMAGE}
echo Built ${IMAGE}
