#!/usr/bin/env bash
set -euo pipefail

cd "$(dirname "$0")/.."
source deploy/env.sh

if [[ ! -f deploy/.last-image ]]; then
  echo "deploy/.last-image puuttuu. Aja ensin ./deploy/build.sh"
  exit 1
fi

IMAGE=$(cat deploy/.last-image)
IMAGE_REPO="${REGISTRY}/${REGISTRY_REPO}"
IMAGE_LATEST="${IMAGE_REPO}:latest"

echo "Pushing:"
echo "  $IMAGE"
echo "  $IMAGE_LATEST"

docker push "$IMAGE"
docker push "$IMAGE_LATEST"

echo "Push OK."
