Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions eng/common/Invoke-ImageBuilder.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Executes ImageBuilder with the specified args.
The args to pass to ImageBuilder.

.PARAMETER ReuseImageBuilderImage
Indicates that a previously built ImageBuilder image is presumed to exist locally and that
Indicates that a previously built ImageBuilder image is presumed to exist locally and that
it should be used for this execution of the script. This allows some optimization when
multiple calls are being made to this script that don't require a fresh image (i.e. the
repo contents in the image don't need to be or should not be updated with each call to
Expand Down Expand Up @@ -74,6 +74,7 @@ try {
}
else {
# On Windows, ImageBuilder is run locally due to limitations with running Docker client within a container.
# Remove when https://github.com/dotnet/docker-tools/issues/159 is resolved
$imageBuilderFolder = ".Microsoft.DotNet.ImageBuilder"
$imageBuilderCmd = [System.IO.Path]::Combine($imageBuilderFolder, "Microsoft.DotNet.ImageBuilder.exe")
if (-not (Test-Path -Path "$imageBuilderCmd" -PathType Leaf)) {
Expand All @@ -99,6 +100,6 @@ finally {
if ($containerCreated) {
Exec "docker container rm -f $imageBuilderContainerName"
}

popd
}
21 changes: 15 additions & 6 deletions eng/dockerfile-templates/Get-GeneratedDockerfiles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@ param(
[switch]$Validate
)

$dockerOs = docker version -f "{{ .Server.Os }}"

$imageBuilderArgs = "generateDockerfiles --optional-templates"
if ($Validate) {
$customImageBuilderArgs = " --validate"
$imageBuilderArgs += " --validate"
}

$repoRoot = (Get-Item "$PSScriptRoot").Parent.Parent.FullName

$onDockerfilesGenerated = {
$onDockerfilesGeneratedLinux = {
param($ContainerName)

if (-Not $Validate) {
Exec "docker cp ${ContainerName}:/repo/src $repoRoot"
}
}

& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 `
-ImageBuilderArgs "generateDockerfiles --optional-templates $customImageBuilderArgs" `
-OnCommandExecuted $onDockerfilesGenerated
# On Windows, ImageBuilder is run locally due to limitations with running Docker client within a container.
# Remove when https://github.com/dotnet/docker-tools/issues/159 is resolved
if ($dockerOs -eq "windows") {
& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 `
-ImageBuilderArgs $imageBuilderArgs
} else {
& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 `
-ImageBuilderArgs $imageBuilderArgs `
-OnCommandExecuted $onDockerfilesGeneratedLinux
}
20 changes: 15 additions & 5 deletions eng/readme-templates/Get-GeneratedReadmes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ param(

$ErrorActionPreference = 'Stop'

$dockerOs = docker version -f "{{ .Server.Os }}"

if ($Validate) {
$customImageBuilderArgs = " --validate"
}
Expand All @@ -16,7 +18,7 @@ function CopyReadme([string]$containerName, [string]$readmeRelativePath) {
Exec "docker cp ${containerName}:/repo/$readmeRelativePath $repoRoot/$readmeDir"
}

$onDockerfilesGenerated = {
$onDockerfilesGeneratedLinux = {
param($ContainerName)

if (-Not $Validate) {
Expand Down Expand Up @@ -44,10 +46,18 @@ $onDockerfilesGenerated = {
function Invoke-GenerateReadme {
param ([string] $Manifest)

& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 `
-ImageBuilderArgs `
"generateReadmes --manifest $Manifest --source-branch 'main'$customImageBuilderArgs 'https://github.com/microsoft/dotnet-framework-docker'" `
-OnCommandExecuted $onDockerfilesGenerated `
$imageBuilderArgs = "generateReadmes --manifest $Manifest --source-branch 'main'$customImageBuilderArgs 'https://github.com/microsoft/dotnet-framework-docker'"

# On Windows, ImageBuilder is run locally due to limitations with running Docker client within a container.
# Remove when https://github.com/dotnet/docker-tools/issues/159 is resolved
if ($dockerOs -eq "windows") {
& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 `
-ImageBuilderArgs $imageBuilderArgs
} else {
& $PSScriptRoot/../common/Invoke-ImageBuilder.ps1 `
-ImageBuilderArgs $imageBuilderArgs `
-OnCommandExecuted $onDockerfilesGeneratedLinux
}
}

Invoke-GenerateReadme "manifest.json"
Expand Down