.PHONY: up down sh install fixtures sync-indexes test

# Start the Docker containers (php, elasticsearch)
up:
	docker compose build --pull php
	docker compose up -d

# Stop the Docker containers
down:
	docker compose down

# Open a bash shell in the container
sh:
	docker compose exec php bash

# Install dependencies with Composer
install:
	docker compose exec php composer install

# (Re)create the search_ac / search_fs / search_sc indexes and load the fixtures
fixtures:
	docker compose exec php sh tests/Fixtures/Es/load.sh

# Regenerate tests/Fixtures/Es/index-*.json from the dbz builders (DBZ=path to a clean dbz checkout)
DBZ ?= ../dbz
sync-indexes:
	docker run --rm --user $$(id -u):$$(id -g) -v $(abspath $(DBZ)):/dbz:ro -v $(CURDIR):/app -w /app php:8.4-cli php tests/Fixtures/Es/dump-indexes.php /dbz

# Run the integration tests (requires make fixtures)
test:
	docker compose exec php bin/phpunit
