param(
    [string]$DockerHost = "ssh://docker-gpu.cin.su",
    [string]$ComposeFile = "core/deploy/docker-gpu/vllm/compose.yaml",
    [string]$EnvFile = "core/deploy/docker-gpu/vllm/.env.example",
    [switch]$ConfigOnly,
    [switch]$Pull
)

$ErrorActionPreference = "Stop"

if (-not (Test-Path -LiteralPath $ComposeFile)) {
    throw "Compose file not found: $ComposeFile"
}

if (-not (Test-Path -LiteralPath $EnvFile)) {
    throw "Env file not found: $EnvFile"
}

$baseArgs = @(
    "--host", $DockerHost,
    "compose",
    "--env-file", $EnvFile,
    "-f", $ComposeFile
)

if ($ConfigOnly) {
    docker @baseArgs config
    exit $LASTEXITCODE
}

if ($Pull) {
    docker @baseArgs pull
    if ($LASTEXITCODE -ne 0) {
        exit $LASTEXITCODE
    }
}

docker @baseArgs up -d
exit $LASTEXITCODE
