#!/usr/bin/env bash

set -eoux -o pipefail

cd "$(dirname "$(realpath "$0")")"
tmpdir=$(mktemp -d)

bazel build //projects/tentacles:tentacles.zapp
zapp=$(realpath $(bazel run --run_under=echo //projects/tentacles:tentacles.zapp))

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

cd "${tmpdir}"
docker build "$@" -f Dockerfile .
