#!/usr/bin/env bash

# Builds the labeling tool and packages it along with all of its runtime
# dependencies into a tarball for deployment.

if [ ! -f WORKSPACE ]; then
  echo 'Must be run from the root of the repository!'
  exit 1
fi

set -exuo pipefail

bazel build //labeling/lt3d/webserver:{uwsgi,manage}

(
  bin_directory='bazel-bin/'
  tar_name="labeling-$(date +"%Y_%m_%d_%H_%M_%S").tar.gz"

  cd "$bin_directory"
  tar --dereference -czf "$tar_name" ./labeling/lt3d/webserver
  echo Tarball available at:
  echo -e "\t$(pwd)/${tar_name}"
)
