#!/bin/bash
# start.sh

MODE=${1:-self-hosted}

if [ "$MODE" == "cloud" ]; then
  echo "Starting in CLOUD mode"
  # Make sure .env has cloud settings
  grep -q "DEPLOYMENT_MODE=cloud" ./backend/.env || \
    sed -i 's/DEPLOYMENT_MODE=.*/DEPLOYMENT_MODE=cloud/' ./backend/.env
  
  # Start with cloud profile
  docker compose --profile cloud up -d
else
  echo "Starting in SELF-HOSTED mode"
  # Make sure .env has self-hosted settings
  grep -q "DEPLOYMENT_MODE=self-hosted" ./backend/.env || \
    sed -i 's/DEPLOYMENT_MODE=.*/DEPLOYMENT_MODE=self-hosted/' ./backend/.env
  
  # Start without extra services
  docker compose up -d
fi
echo "Deployment complete in $MODE mode"