# 重新构建并启动指定服务（依赖或 Dockerfile 变更时使用）
param(
    [Parameter(Mandatory = $true)]
    [ValidateSet("backend", "frontend")]
    [string]$Service
)

$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
Set-Location $Root

Write-Host "Rebuilding and starting $Service..." -ForegroundColor Cyan
docker compose up -d --build $Service

if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

Write-Host "Done. $Service rebuilt and running." -ForegroundColor Green
