#!/bin/bash

# script/setup: Set up container for the first time after cloning

set -e

cd "$(dirname "$0")/.."

source version

script/bootstrap

echo "==> Setting up container kontor-spring"
if podman image exists localhost/kontor-spring:i$kontorVersion; then
    echo "  => Image localhost/kontor-spring:$kontorVersion available"
fi
if podman container exists kontor-spring; then
    if podman ps -q --filter "name=kontor-spring"; then
        echo "  => kontor-spring is running"
    fi
else
    podman run -d \
        --replace \
        --pod kontor \
        --name kontor-spring \
        --label "io.containers.autoupdate=local" \
        --label "PODMAN_SYSTEMD_UNIT=kontor-spring.service" \
        localhost/kontor-spring:$kontorVersion
fi

