param(
    [ValidateSet("start", "stop", "logs", "test")]
    [string]$Action = "start",
    [string]$Service = "php1"
)

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$RootDir = Split-Path -Parent $PSScriptRoot
Set-Location $RootDir

switch ($Action) {
    "start" {
        docker compose up -d traefik redis mysql-debug php1 caddy
    }
    "stop" {
        docker compose down
    }
    "logs" {
        docker compose logs -f --tail=200 $Service
    }
    "test" {
        docker compose exec -T php1 sh -lc "cd /var/www/html && composer test:unit"
    }
}
