#!/bin/bash
# Build, tag, and push robot proxy docker images to our registry
#
# Usage: ./build_robot_proxy_docker_images.sh <tag>
#
# If you don't provide an argument, tag will default to latest
# By convention, we use the current date as the tag, ex: 20180820

set -euo pipefail

tag=${1:-latest}

# Find workspace and set up env
workspace=$(bazel info workspace)
cd ${workspace}
source "$workspace/scripts/shell/bazel/function.sh"

# Pull the latest dds_base since it is used by all of the other images
./docker_images/teleop/dds_base/pull.sh

echo "Building dds chum recorder image: $tag"
bazel_run //teleop/ziod/logger/chum:push_dds_chum_recorder_image --define dds_chum_recorder_image_tag=$tag

echo "Building vitals telemetry utility image: $tag"
bazel_run //teleop/ziod/utilities:push_vitals_telemetry_image --define vitals_telemetry_image_tag=$tag

echo "Building robot proxy image: $tag"
bazel_run //teleop/ziod/robot_proxy:push_robot_proxy_image --define robot_proxy_image_tag=$tag

echo "Building spooler image: $tag"
bazel_run //teleop/reporting:push_report_spooler_image --define report_spooler_image_tag=$tag
