|
18 | 18 | [string]$Script = 'Build.ps1', # The build script to be executed inside Docker. |
19 | 19 | [string]$Isolation = 'process', # Docker isolation mode (process or hyperv). |
20 | 20 | [string]$Memory = '8g', # Docker memory limit. |
| 21 | + [int]$Cpus = [Environment]::ProcessorCount, # Docker CPU limit (defaults to host's CPU count). |
21 | 22 | [Parameter(ValueFromRemainingArguments)] |
22 | 23 | [string[]]$BuildArgs # Arguments passed to `Build.ps1` within the container (or Claude prompt if -Claude is specified). |
23 | 24 | ) |
@@ -916,8 +917,8 @@ if (-not $BuildImage) |
916 | 917 | try |
917 | 918 | { |
918 | 919 | # Start new container with docker run |
919 | | - Write-Host "Executing: docker run --rm --memory=$Memory --isolation=$Isolation $dockerArgsAsString $VolumeMappingsAsString -e HOME=$containerUserProfile -e USERPROFILE=$containerUserProfile -w $ContainerSourceDir $ImageTag `"$pwshPath`" -Command `"$inlineScript`"" -ForegroundColor Cyan |
920 | | - docker run --rm --memory=$Memory --isolation=$Isolation $dockerArgs @volumeArgs @envArgs -w $ContainerSourceDir $ImageTag $pwshPath -Command $inlineScript |
| 920 | + Write-Host "Executing: docker run --rm --memory=$Memory --cpus=$Cpus --isolation=$Isolation $dockerArgsAsString $VolumeMappingsAsString -e HOME=$containerUserProfile -e USERPROFILE=$containerUserProfile -w $ContainerSourceDir $ImageTag `"$pwshPath`" -Command `"$inlineScript`"" -ForegroundColor Cyan |
| 921 | + docker run --rm --memory=$Memory --cpus=$Cpus --isolation=$Isolation $dockerArgs @volumeArgs @envArgs -w $ContainerSourceDir $ImageTag $pwshPath -Command $inlineScript |
921 | 922 | $dockerExitCode = $LASTEXITCODE |
922 | 923 | } |
923 | 924 | finally |
@@ -1039,8 +1040,8 @@ if (-not $BuildImage) |
1039 | 1040 | else |
1040 | 1041 | { |
1041 | 1042 | # Start new container with docker run |
1042 | | - Write-Host "Executing: ``docker run --rm --memory=$Memory --isolation=$Isolation $dockerArgsAsString $VolumeMappingsAsString -w $ContainerSourceDir $ImageTag `"$pwshPath`" $pwshArgs -Command `"$inlineScript`"" -ForegroundColor Cyan |
1043 | | - docker run --rm --memory=$Memory --isolation=$Isolation $dockerArgs @volumeArgs -w $ContainerSourceDir $ImageTag $pwshPath $pwshArgs -Command $inlineScript |
| 1043 | + Write-Host "Executing: ``docker run --rm --memory=$Memory --cpus=$Cpus --isolation=$Isolation $dockerArgsAsString $VolumeMappingsAsString -w $ContainerSourceDir $ImageTag `"$pwshPath`" $pwshArgs -Command `"$inlineScript`"" -ForegroundColor Cyan |
| 1044 | + docker run --rm --memory=$Memory --cpus=$Cpus --isolation=$Isolation $dockerArgs @volumeArgs -w $ContainerSourceDir $ImageTag $pwshPath $pwshArgs -Command $inlineScript |
1044 | 1045 | } |
1045 | 1046 |
|
1046 | 1047 | if ($LASTEXITCODE -ne 0) |
|
0 commit comments