#!/usr/bin/env bash set -euo pipefail SERVICE=waxwing WEB_PORT=8521 API_PORT=8522 COMPOSE_FILE="compose.yml" OVERRIDE_FLAG="" [[ -f "compose.override.yml" ]] && OVERRIDE_FLAG="-f compose.override.yml" usage() { echo "Usage: $0 {start|stop|restart|status|logs|open|build|test|update}" echo "" echo " start Build (if needed) and start all services" echo " stop Stop and remove containers" echo " restart Stop then start" echo " status Show running containers" echo " logs [svc] Follow logs (api | web — defaults to all)" echo " open Open web UI in browser" echo " build Rebuild Docker images without cache" echo " test Run pytest test suite" echo " update git pull + rebuild + restart" exit 1 } cmd="${1:-help}" shift || true case "$cmd" in start) docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build echo "Waxwing running → http://localhost:${WEB_PORT}" ;; stop) docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG down ;; restart) docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG down docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build echo "Waxwing running → http://localhost:${WEB_PORT}" ;; status) docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG ps ;; logs) svc="${1:-}" docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG logs -f ${svc} ;; open) xdg-open "http://localhost:${WEB_PORT}" 2>/dev/null \ || open "http://localhost:${WEB_PORT}" 2>/dev/null \ || echo "Open http://localhost:${WEB_PORT} in your browser" ;; build) docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG build --no-cache ;; test) conda run -n cf python -m pytest tests/ -v ;; update) git pull docker compose -f "$COMPOSE_FILE" $OVERRIDE_FLAG up -d --build echo "Waxwing updated → http://localhost:${WEB_PORT}" ;; *) usage ;; esac