Fix Ci/Cd: Get Node another way — try Gitea cache, then Arvan / AWS / GCR, and only then Docker Hub; once pulled, store it on Gitea for next time. #74
@@ -1,5 +1,6 @@
|
||||
# Prefer a Gitea-hosted node:20-alpine so docker build does not HEAD registry-1.docker.io.
|
||||
# Order: local Gitea tag → pull Gitea → local Docker Hub tag → pull Hub (retries) → tag/push Gitea.
|
||||
# Order: local Gitea tag -> pull Gitea -> local Docker Hub tag -> pull Hub (retries) -> tag/push Gitea.
|
||||
# ASCII only: Windows PowerShell 5.1 + act_runner mis-parses backtick escapes in this file.
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$RegistryPrefix,
|
||||
[string]$OutFile = '.ci-node-image',
|
||||
@@ -8,6 +9,7 @@ param(
|
||||
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$mirror = "$RegistryPrefix/node:20-alpine"
|
||||
$nl = [char]10
|
||||
|
||||
function Test-Image([string]$Name) {
|
||||
docker image inspect $Name 2>&1 | Out-Null
|
||||
@@ -26,7 +28,8 @@ function Invoke-Pull([string]$Name, [int]$Attempts) {
|
||||
|
||||
function Save-Choice([string]$Name) {
|
||||
$utf8 = New-Object System.Text.UTF8Encoding $false
|
||||
[System.IO.File]::WriteAllText((Join-Path (Get-Location) $OutFile), $Name + "`n", $utf8)
|
||||
$path = Join-Path (Get-Location) $OutFile
|
||||
[System.IO.File]::WriteAllText($path, ($Name + $nl), $utf8)
|
||||
Write-Host "NODE_IMAGE=$Name"
|
||||
}
|
||||
|
||||
@@ -59,9 +62,9 @@ if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
docker push $mirror
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Could not push $mirror — docker build will use the local tag (legacy builder)."
|
||||
$utf8 = New-Object System.Text.UTF8Encoding $false
|
||||
[System.IO.File]::WriteAllText((Join-Path (Get-Location) '.ci-use-legacy-builder'), "1`n", $utf8)
|
||||
Write-Host "Could not push $mirror - docker build will use the local tag (legacy builder)."
|
||||
$flag = Join-Path (Get-Location) '.ci-use-legacy-builder'
|
||||
New-Item -ItemType File -Path $flag -Force | Out-Null
|
||||
}
|
||||
|
||||
Save-Choice $mirror
|
||||
|
||||
Reference in New Issue
Block a user