#!/usr/bin/env bash

set -euo pipefail

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

tag="$1"
live_transcoding_image_name="argus.docker.zooxlabs.com/live-transcoding:$tag"

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

(
  set -x
  bazel build //argus/live_transcoding_service:websocket_service_image.tar

  docker load -i $(bazel info bazel-bin)/argus/live_transcoding_service/websocket_service_image.tar

  docker tag bazel/argus/live_transcoding_service:websocket_service_image "$live_transcoding_image_name"

  docker push "$live_transcoding_image_name"
)

echo Success!
