@@ -37,20 +37,22 @@ param(
|
||||
[switch]$push
|
||||
)
|
||||
|
||||
$arguments = @(
|
||||
$basetags = @()
|
||||
|
||||
$regstryid = $(& (Get-Command 'docker').source run --rm -d -p 8192:5000 registry:2)
|
||||
|
||||
ForEach($platform in $platforms.Split(",")) {
|
||||
$arguments = @(
|
||||
'buildx',
|
||||
'build'
|
||||
)
|
||||
)
|
||||
|
||||
$arguments += $push -eq $True ? @("--push") : @()
|
||||
$arguments += $progress -ne 'plain' ? @("--progress=$progress") : @("--progress=plain")
|
||||
|
||||
$arguments += $progress -ne 'plain' ? @("--progress=$progress") : @("--progress=plain")
|
||||
$intermediatetag = "localhost:8192/intermediate:$($platform.Replace("/", "-"))"
|
||||
|
||||
$tags.Count -ne 0 ? ($tags | ForEach-Object { $arguments += @("--tag=$_") }) : ""
|
||||
|
||||
$arguments += $tag -ne '' ? @("--tag=$tag") : @()
|
||||
|
||||
$arguments += @(
|
||||
$arguments += @(
|
||||
"--tag=${intermediatetag}",
|
||||
"--build-arg=NODE_VERSION=${node}",
|
||||
"--build-arg=DISTRO=${distro}",
|
||||
"--build-arg=TYPE=${type}",
|
||||
@@ -65,8 +67,55 @@ $arguments += @(
|
||||
"--build-arg=FROM_IMAGE=${from_image}",
|
||||
"--build-arg=FROM_TAG=${from_tag}",
|
||||
"--file=./linux/${image}/Dockerfile",
|
||||
"--platform=${platforms}",
|
||||
"--platform=${platform}",
|
||||
"--load",
|
||||
'.'
|
||||
)
|
||||
)
|
||||
|
||||
& (Get-Command 'docker').source $arguments
|
||||
& (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=$_") }) : ""
|
||||
|
||||
$arguments += $tag -ne '' ? @("--tag=$tag") : @()
|
||||
|
||||
& (Get-Command 'docker').source buildx imagetools create $arguments $basetags
|
||||
|
||||
& (Get-Command 'docker').source stop $regstryid
|
||||
|
||||
Reference in New Issue
Block a user