@@ -37,36 +37,85 @@ param(
|
|||||||
[switch]$push
|
[switch]$push
|
||||||
)
|
)
|
||||||
|
|
||||||
$arguments = @(
|
$basetags = @()
|
||||||
'buildx',
|
|
||||||
'build'
|
|
||||||
)
|
|
||||||
|
|
||||||
$arguments += $push -eq $True ? @("--push") : @()
|
$regstryid = $(& (Get-Command 'docker').source run --rm -d -p 8192:5000 registry:2)
|
||||||
|
|
||||||
$arguments += $progress -ne 'plain' ? @("--progress=$progress") : @("--progress=plain")
|
ForEach($platform in $platforms.Split(",")) {
|
||||||
|
$arguments = @(
|
||||||
|
'buildx',
|
||||||
|
'build'
|
||||||
|
)
|
||||||
|
|
||||||
|
$arguments += $progress -ne 'plain' ? @("--progress=$progress") : @("--progress=plain")
|
||||||
|
|
||||||
|
$intermediatetag = "localhost:8192/intermediate:$($platform.Replace("/", "-"))"
|
||||||
|
|
||||||
|
$arguments += @(
|
||||||
|
"--tag=${intermediatetag}",
|
||||||
|
"--build-arg=NODE_VERSION=${node}",
|
||||||
|
"--build-arg=DISTRO=${distro}",
|
||||||
|
"--build-arg=TYPE=${type}",
|
||||||
|
"--build-arg=RUNNER=${runner}",
|
||||||
|
"--build-arg=BUILD_DATE=$((Get-Date).ToString('u'))",
|
||||||
|
"--build-arg=BUILD_OWNER=${owner}",
|
||||||
|
"--build-arg=BUILD_OWNER_MAIL=${owner}",
|
||||||
|
"--build-arg=BUILD_REPO=${repository}",
|
||||||
|
"--build-arg=BUILD_TAG=${build_tag}",
|
||||||
|
"--build-arg=BUILD_TAG_VERSION=${build_tag_version}",
|
||||||
|
"--build-arg=BUILD_REF=${build_ref}",
|
||||||
|
"--build-arg=FROM_IMAGE=${from_image}",
|
||||||
|
"--build-arg=FROM_TAG=${from_tag}",
|
||||||
|
"--file=./linux/${image}/Dockerfile",
|
||||||
|
"--platform=${platform}",
|
||||||
|
"--load",
|
||||||
|
'.'
|
||||||
|
)
|
||||||
|
|
||||||
|
& (Get-Command 'docker').source $arguments
|
||||||
|
|
||||||
|
# Not using buildx here, because buildx doesn't like a localhost registry
|
||||||
|
$arguments = @(
|
||||||
|
'build'
|
||||||
|
)
|
||||||
|
|
||||||
|
$arguments += $progress -ne 'plain' ? @("--progress=$progress") : @("--progress=plain")
|
||||||
|
|
||||||
|
$imageid = $(& (Get-Command 'docker').source create "${intermediatetag}")
|
||||||
|
|
||||||
|
$envfileContent = $(& (Get-Command 'docker').source cp "${imageid}:/etc/environment" - | tar x --to-stdout)
|
||||||
|
|
||||||
|
& (Get-Command 'docker').source rm "${imageid}"
|
||||||
|
|
||||||
|
echo "FROM ${intermediatetag}" > Dockerfile.tmp
|
||||||
|
|
||||||
|
ForEach($envline in $envfileContent.Split("\n")) {
|
||||||
|
echo "ENV $envline" >> Dockerfile.tmp
|
||||||
|
}
|
||||||
|
|
||||||
|
$arguments += @(
|
||||||
|
"--tag=${intermediatetag}",
|
||||||
|
"--file=./Dockerfile.tmp",
|
||||||
|
'.'
|
||||||
|
)
|
||||||
|
|
||||||
|
& (Get-Command 'docker').source $arguments
|
||||||
|
|
||||||
|
& (Get-Command 'docker').source push ${intermediatetag}
|
||||||
|
|
||||||
|
$basetags += @("${intermediatetag}")
|
||||||
|
}
|
||||||
|
|
||||||
|
$arguments = @()
|
||||||
|
|
||||||
|
if($push -ne $true) {
|
||||||
|
$arguments += @("--dry-run")
|
||||||
|
}
|
||||||
|
|
||||||
$tags.Count -ne 0 ? ($tags | ForEach-Object { $arguments += @("--tag=$_") }) : ""
|
$tags.Count -ne 0 ? ($tags | ForEach-Object { $arguments += @("--tag=$_") }) : ""
|
||||||
|
|
||||||
$arguments += $tag -ne '' ? @("--tag=$tag") : @()
|
$arguments += $tag -ne '' ? @("--tag=$tag") : @()
|
||||||
|
|
||||||
$arguments += @(
|
& (Get-Command 'docker').source buildx imagetools create $arguments $basetags
|
||||||
"--build-arg=NODE_VERSION=${node}",
|
|
||||||
"--build-arg=DISTRO=${distro}",
|
|
||||||
"--build-arg=TYPE=${type}",
|
|
||||||
"--build-arg=RUNNER=${runner}",
|
|
||||||
"--build-arg=BUILD_DATE=$((Get-Date).ToString('u'))",
|
|
||||||
"--build-arg=BUILD_OWNER=${owner}",
|
|
||||||
"--build-arg=BUILD_OWNER_MAIL=${owner}",
|
|
||||||
"--build-arg=BUILD_REPO=${repository}",
|
|
||||||
"--build-arg=BUILD_TAG=${build_tag}",
|
|
||||||
"--build-arg=BUILD_TAG_VERSION=${build_tag_version}",
|
|
||||||
"--build-arg=BUILD_REF=${build_ref}",
|
|
||||||
"--build-arg=FROM_IMAGE=${from_image}",
|
|
||||||
"--build-arg=FROM_TAG=${from_tag}",
|
|
||||||
"--file=./linux/${image}/Dockerfile",
|
|
||||||
"--platform=${platforms}",
|
|
||||||
'.'
|
|
||||||
)
|
|
||||||
|
|
||||||
& (Get-Command 'docker').source $arguments
|
& (Get-Command 'docker').source stop $regstryid
|
||||||
|
|||||||
Reference in New Issue
Block a user