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

ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "${ROOT}/backend"

# shellcheck disable=SC1091
source venv/bin/activate

if [[ -f "${ROOT}/.env" ]]; then
  set -a
  # shellcheck disable=SC1090
  source "${ROOT}/.env"
  set +a
fi

export FRONTEND_DIST="${FRONTEND_DIST:-${ROOT}/frontend/dist}"
export UPLOAD_DIR="${UPLOAD_DIR:-${ROOT}/uploads}"
export OPENCV_IO_ENABLE_OPENEXR=0

exec python -m uvicorn app.main:app --host 0.0.0.0 --port "${WEB_PORT:-23566}"
