#!zsh
set -e

#docker run -p 8080:8080 ghcr.io/willnorris/imageproxy -addr 0.0.0.0:8080

pod=real-time-insights
podman pod exists $pod || podman pod create --name $pod --publish 8080

version=${VERSION:-latest}
backend=ama-backend
podman image exists ama-backend:$version || podman image build \
  --tag $version \
  --file Dockerfile ./ama-backend

podman container exists $backend:$version || podman run \
  --name $backend:$version \
  --pod $pod \
  --detach \
  --tty \
    $backend

podman pod ps

#start() {
#  tag=${TAG:-$(date +%m%d)}
#  image=$1; shift
#  context=$1; shift
#  args=$@
#
#  maybe-build $image:$tag 
#  podman start $image:$tag $args
#}
#
#maybe-build() {
#  image=$1
#  context=$2
#  exists $image|| build $image $context
#}
#
#exists() {
#  image=$1
#  podman pod exists $image
#}
#
#build() {
#  image=$1
#  directory=$2
#  podman build --tag $image $2
#}
#
#
#docker run -p 8080:8080 ghcr.io/willnorris/imageproxy -addr 0.0.0.0:8080
