#!/bin/bash

# print menu: (1) deploy stack, (2) follow logs of "web-app" service, (3) remove stack
echo "1. Deploy stack"
echo "2. Follow logs of 'web-app' service"
echo "3. Remove stack"
echo ""
echo "Ctrl+C to exit"
echo ""

# read user input
read -p "Enter your choice: " -n 1 -r
echo ""

# deploy stack
if [ $REPLY -eq 1 ]
then
    #docker stack deploy -c docker-compose-deploy.yml utility-bills-tracker
    HOSTNAME=0.0.0.0 \
    NEXTAUTH_URL=https://rezije.app \
    docker stack deploy \
        -c docker-compose-deploy.yml utility-bills-tracker
fi

# follow logs of "web-app" service
if [ $REPLY -eq 2 ]
then
    docker service logs -f utility-bills-tracker_web-app
fi

# remove stack
if [ $REPLY -eq 3 ]
then
    docker stack rm utility-bills-tracker
fi

# go back to menu
./debug-deploy.sh