#!/bin/bash

set -euo pipefail;

source utils.sh


AWS_PROFILE=""
MONITOR=0


for i in "$@"; do
  case $i in
    -p=*|--aws-profile=*)
      AWS_PROFILE="${i#*=}"
      shift
      ;;
    -m|--monitor)
      MONITOR=1
      shift
      ;;
    -*|--*)
      echo "Unknown option $i"
      exit 1
      ;;
    *)
      ;;
  esac
done

renew_aws_session ${AWS_PROFILE}
set_env_variables

find . -name \*.pyc -delete
mkdir -p ./logs

if (( ${MONITOR} == 1 )); then
  docker-compose --profile monitor up --build
else
  docker-compose up --build
fi
