#!/bin/sh
set -e

echo "👀 Watching Laravel source files for changes..."
echo "📁 Monitoring: /app"
echo "🚫 Ignoring: vendor node_modules storage bootstrap/cache"

inotifywait -m -r -e modify,create,delete,move \
  --exclude 'vendor|node_modules|storage|bootstrap/cache' /app |
while read path action file; do
  echo "🔄 Change detected: ${path}${file} (${action})"
  echo "♻️ Rebuilding Laravel containers..."
  docker compose up -d --build
done
