#!/usr/bin/env bash

set -euo pipefail

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

tag="$1"
image_name="infra.docker.zooxlabs.com/fs_stats:$tag"
(
  set -x
  bazel run fs_stats_image -- --norun
  docker tag bazel/pipedream/monitoring/collectors/fs_stats:fs_stats_image "$image_name"
  docker push "$image_name"
)

echo Success!
echo Update the version in infra/ansible/pipedream-collectors/defaults/main.yml.
echo Deploy to production using:
echo   ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook -i inventory/slurm/production slurm_cluster.yml -u zoox --tags collectors
echo add --limit [node name] to limit to deploying to certain nodes
