#!/usr/bin/env bash

set -eoux -o pipefail

cd "$(dirname "$(realpath "$0")")"
tmpdir=$(mktemp -d)
target="//projects/tickertape:tickertape.zapp"

bazel build "${target}"
zapp=$(realpath $(bazel run --run_under=echo "${target}"))

cp Dockerfile "$tmpdir/"
cp -r "$zapp" "$tmpdir/"

cd "${tmpdir}"
docker build "$@" -f Dockerfile -t registry.tirefireind.us/arrdem/tickertape:latest .
docker push registry.tirefireind.us/arrdem/tickertape:latest