#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
IMAGE_REF="${1:-}"
DOCKER_PLATFORM="${DOCKER_PLATFORM:-linux/amd64}"

if [ -z "${IMAGE_REF}" ]; then
  echo "usage: ci/build-image.sh <image-ref>" >&2
  exit 1
fi

cd "${ROOT_DIR}"
docker build --platform "${DOCKER_PLATFORM}" -t "${IMAGE_REF}" .
