#!/usr/bin/env bash

set -euo pipefail

if [[ -z "${1:-}" || "$1" == '--help' || "$1" == '-h' ]]; then
  echo "Usage: $0 TAG"
  exit 1
fi

tag="$1"
annotation_3d_image_name="pcp.docker.zooxlabs.com/annotation-3d-service:$tag"

cd "$( (builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) )"

(
  set -x
  bazel build //vision/data/tools/annotation_3d_service:service_image.tar
  docker load -i $(bazel info bazel-bin)/vision/data/tools/annotation_3d_service/service_image.tar
  docker tag bazel/vision/data/tools/annotation_3d_service:service_image "$annotation_3d_image_name"
  docker push "$annotation_3d_image_name"
)

echo Success!
