#!/usr/bin/env bash
# Rebuilds the frontend Docker container and refreshes the node_modules volume.
# Run this after adding or updating npm dependencies.
set -euo pipefail

cd "$(dirname "$0")/.."

echo "Stopping frontend container..."
docker compose stop frontend

echo "Removing frontend container..."
docker compose rm -f frontend

echo "Removing stale node_modules volume..."
docker volume rm familienarchiv_frontend_node_modules 2>/dev/null || true

echo "Rebuilding image and starting container..."
docker compose up -d --build frontend

echo "Done. Tailing logs (Ctrl+C to exit)..."
docker compose logs -f frontend
