#!/bin/bash
# Make the script exit when a command fails.
set -e

# Define a cleanup function to handle CTRL-C (SIGINT)
cleanup() {
    echo "CTRL-C caught! Shutting down Docker Compose services..."
    docker compose down
    exit 1
}

# Set trap to call cleanup() when SIGINT (Ctrl-C) is received.
trap cleanup SIGINT

# Restart compose services.
echo "Restarting compose services..."
docker compose down
docker compose up -d

#docker compose exec web bash -c "cd /code/theme/static_src && npm run dev" || true
uv run python manage.py runserver &
cd theme/static_src
uv run npm run dev

docker compose down
echo "Done!"