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

# Dev mode for sx_docs only (standalone, no DB)
# Bind-mounted source + auto-reload on externalnet
# Browse to sx.rose-ash.com
#
# Usage:
#   ./dev-sx.sh              # Start sx_docs dev
#   ./dev-sx.sh down          # Stop
#   ./dev-sx.sh logs          # Tail logs
#   ./dev-sx.sh --build       # Rebuild image then start

COMPOSE="docker compose -p sx-dev -f docker-compose.dev-sx.yml"

case "${1:-up}" in
  down)
    $COMPOSE down
    ;;
  logs)
    $COMPOSE logs -f sx_docs
    ;;
  *)
    BUILD_FLAG=""
    if [[ "${1:-}" == "--build" ]]; then
      BUILD_FLAG="--build"
    fi
    $COMPOSE up $BUILD_FLAG
    ;;
esac
