fix(deploy): 浅克隆说明、README 精简与 Docker 自动安装可观测性
Test start.ps1 (Windows) / test-windows (push) Waiting to run
Test start.ps1 (Windows) / test-windows (push) Waiting to run
- README: Windows 一条 PowerShell 命令,保留脚本权限说明;合并重复段落 - start.sh/ps1: git clone --depth 1 示例 - start.ps1: 选 [2] 时输出 winget/choco 日志与退出码,失败原因可辨;Read-Host Trim;winget 后若 docker 可用则视为成功 Made-with: Cursor
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#Requires -Version 5.1
|
||||
#
|
||||
# 从 Git 克隆后首次部署(推荐分行复制执行,避免参数被误传给 git):
|
||||
# git clone "https://git.51easyai.com/wangbo/easyai.git" "easyai"
|
||||
# 从 Git 克隆后首次部署(推荐分行复制执行,避免参数被误传给 git;浅克隆加 --depth 1):
|
||||
# git clone --depth 1 "https://git.51easyai.com/wangbo/easyai.git" "easyai"
|
||||
# Set-Location ".\easyai"
|
||||
# powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\start.ps1"
|
||||
#
|
||||
# 若必须一行,请用分号分隔整条链,且 -File 后必须是带引号的脚本路径(不要用 Istart.ps1,应为 .\start.ps1):
|
||||
# git clone "https://git.51easyai.com/wangbo/easyai.git" "easyai"; Set-Location "easyai"; powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\start.ps1"
|
||||
# git clone --depth 1 "https://git.51easyai.com/wangbo/easyai.git" "easyai"; Set-Location "easyai"; powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\start.ps1"
|
||||
#
|
||||
# 若出现 error: unknown switch 'E':说明 -ExecutionPolicy 被交给了 git(可复现:git clone URL -ExecutionPolicy)。
|
||||
# 常见原因:整段命令未用分号分隔、或把 powershell 与 git 写在同一行且参数被 git 解析。
|
||||
@@ -208,18 +208,57 @@ function Ensure-DockerRunning {
|
||||
}
|
||||
|
||||
function Install-DockerDesktop {
|
||||
if (Get-Command winget -ErrorAction SilentlyContinue) {
|
||||
function Test-Winget {
|
||||
return [bool](Get-Command winget -ErrorAction SilentlyContinue)
|
||||
}
|
||||
function Test-Choco {
|
||||
return [bool](Get-Command choco -ErrorAction SilentlyContinue)
|
||||
}
|
||||
if (Test-Winget) {
|
||||
Step "Installing Docker Desktop via winget..."
|
||||
winget install --id Docker.DockerDesktop -e --accept-source-agreements --accept-package-agreements
|
||||
if ($LASTEXITCODE -eq 0) { Ok "Install started. Reopen terminal and rerun script."; exit 0 }
|
||||
Write-Log "winget install Docker.DockerDesktop"
|
||||
$wingetOut = & winget install --id Docker.DockerDesktop -e --accept-source-agreements --accept-package-agreements 2>&1
|
||||
$wingetOut | ForEach-Object { Write-Host $_ }
|
||||
$wingetCode = $LASTEXITCODE
|
||||
Write-Log "winget exit code: $wingetCode"
|
||||
if ($wingetCode -eq 0) {
|
||||
Ok "Install started. Reopen terminal and rerun script."
|
||||
Write-Log "winget reported success"
|
||||
exit 0
|
||||
}
|
||||
if (Test-DockerInstalled) {
|
||||
Ok "Docker CLI detected after winget. Reopen terminal if docker commands fail, then rerun script."
|
||||
Write-Log "winget exit $wingetCode but docker is available"
|
||||
exit 0
|
||||
}
|
||||
Warn "winget did not report success (exit code: $wingetCode). Trying Chocolatey if available..."
|
||||
} else {
|
||||
Warn "winget not found (install 'App Installer' from Microsoft Store or use Windows 11 / recent Windows 10). Trying Chocolatey if available..."
|
||||
}
|
||||
if (Get-Command choco -ErrorAction SilentlyContinue) {
|
||||
|
||||
if (Test-Choco) {
|
||||
Step "Installing Docker Desktop via choco..."
|
||||
choco install docker-desktop -y
|
||||
if ($LASTEXITCODE -eq 0) { Ok "Install started. Reopen terminal and rerun script."; exit 0 }
|
||||
Write-Log "choco install docker-desktop"
|
||||
$chocoOut = & choco install docker-desktop -y 2>&1
|
||||
$chocoOut | ForEach-Object { Write-Host $_ }
|
||||
$chocoCode = $LASTEXITCODE
|
||||
Write-Log "choco exit code: $chocoCode"
|
||||
if ($chocoCode -eq 0) {
|
||||
Ok "Install started. Reopen terminal and rerun script."
|
||||
exit 0
|
||||
}
|
||||
if (Test-DockerInstalled) {
|
||||
Ok "Docker CLI detected after choco. Reopen terminal if docker commands fail, then rerun script."
|
||||
exit 0
|
||||
}
|
||||
Warn "choco did not report success (exit code: $chocoCode)."
|
||||
} else {
|
||||
Warn "Chocolatey (choco) not found."
|
||||
}
|
||||
Warn "Please install Docker Desktop manually:"
|
||||
|
||||
Warn "Automatic install was not completed. Please install Docker Desktop manually:"
|
||||
Write-Host " $script:DockerDesktopUrl"
|
||||
Write-Log "Docker auto-install failed (winget/choco unavailable or non-zero exit)"
|
||||
Wait-ForExit
|
||||
exit 1
|
||||
}
|
||||
@@ -241,7 +280,7 @@ function Test-Docker {
|
||||
Write-Host "Choose:"
|
||||
Write-Host " [1] Manual install (open URL and exit)"
|
||||
Write-Host " [2] Auto install (winget/choco)"
|
||||
$choice = Read-Host "Select [1/2]"
|
||||
$choice = (Read-Host "Select [1/2]").Trim()
|
||||
switch ($choice) {
|
||||
"1" { Start-Process $script:DockerDesktopUrl; Wait-ForExit; exit 1 }
|
||||
"2" { Install-DockerDesktop }
|
||||
|
||||
Reference in New Issue
Block a user