-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Update docker file for windows build #5459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
TravisEz13
merged 7 commits into
PowerShell:master
from
TravisEz13:working_signing_fixes
Nov 28, 2017
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5bafd43
add required module for docker image
TravisEz13 bfcb066
update windows build DockerFile to be based on microsoft/windowsserve…
TravisEz13 2d19e70
add wix install helper
TravisEz13 9a7481a
tell docker based build to include Dependant module
TravisEz13 63c054d
remove unneeded assignment to null
TravisEz13 db6c02f
Address PR feedback
TravisEz13 b64187a
address PR comments
TravisEz13 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
23 changes: 20 additions & 3 deletions
23
tools/releaseBuild/Images/microsoft_powershell_windowsservercore/DockerFile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,28 @@ | ||
| # escape=` | ||
| #0.3.6 (no powershell 6) | ||
| FROM travisez13/microsoft.windowsservercore.build-tools:latest | ||
| FROM microsoft/windowsservercore | ||
| LABEL maintainer='PowerShell Team <powershellteam@hotmail.com>' | ||
| LABEL description="This Dockerfile for Windows Server Core with git installed via chocolatey." | ||
|
|
||
| SHELL ["powershell"] | ||
| SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"] | ||
| # Install Git, and NuGet | ||
| # Git installs to C:\Program Files\Git | ||
| # nuget installs to C:\ProgramData\chocolatey\bin\NuGet.exe | ||
| COPY dockerInstall.psm1 containerFiles/dockerInstall.psm1 | ||
| RUN Import-Module ./containerFiles/dockerInstall.psm1; ` | ||
| Install-ChocolateyPackage -PackageName git -Executable git.exe; ` | ||
| Install-ChocolateyPackage -PackageName nuget.commandline -Executable nuget.exe -Cleanup | ||
|
|
||
| # Install WIX | ||
| ADD https://github.com/wixtoolset/wix3/releases/download/wix311rtm/wix311-binaries.zip /wix.zip | ||
| COPY wix.psm1 containerFiles/wix.psm1 | ||
| RUN Import-Module ./containerFiles/wix.psm1; ` | ||
| Install-WixZip -zipPath \wix.Zip | ||
|
|
||
| COPY PowerShellPackage.ps1 / | ||
|
|
||
| ENTRYPOINT ["powershell"] | ||
| ADD https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 \install-powershell.ps1 | ||
| RUN new-item -Path 'C:\Program Files\PowerShell\latest' -ItemType Directory; ` | ||
| \install-powershell.ps1 -AddToPath -Destination 'C:\Program Files\PowerShell\latest' | ||
|
|
||
| ENTRYPOINT ["C:\\Program Files\\PowerShell\\latest\\pwsh.exe", "-command"] |
113 changes: 113 additions & 0 deletions
113
tools/releaseBuild/Images/microsoft_powershell_windowsservercore/dockerInstall.psm1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| function Install-ChocolateyPackage | ||
| { | ||
| param( | ||
| [Parameter(Mandatory=$true)] | ||
| [string] | ||
| $PackageName, | ||
|
|
||
| [Parameter(Mandatory=$false)] | ||
| [string] | ||
| $Executable, | ||
|
|
||
| [string[]] | ||
| $ArgumentList, | ||
|
|
||
| [switch] | ||
| $Cleanup, | ||
|
|
||
| [int] | ||
| $ExecutionTimeout = 2700, | ||
|
|
||
| [string] | ||
| $Version | ||
| ) | ||
|
|
||
| if(-not(Get-Command -name Choco -ErrorAction SilentlyContinue)) | ||
| { | ||
| Write-Verbose "Installing Chocolatey provider..." -Verbose | ||
| Invoke-WebRequest https://chocolatey.org/install.ps1 -UseBasicParsing | Invoke-Expression | ||
| } | ||
|
|
||
| Write-Verbose "Installing $PackageName..." -Verbose | ||
| $extraCommand = @() | ||
| if($Version) | ||
| { | ||
| $extraCommand += '--version', $version | ||
| } | ||
| choco install -y $PackageName --no-progress --execution-timeout=$ExecutionTimeout $ArgumentList $extraCommands | ||
|
|
||
| if($executable) | ||
| { | ||
| Write-Verbose "Verifing $Executable is in path..." -Verbose | ||
| $exeSource = $null | ||
| $exeSource = Get-ChildItem -path "$env:ProgramFiles\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName | ||
| if(!$exeSource) | ||
| { | ||
| Write-Verbose "Falling back to x86 program files..." -Verbose | ||
| $exeSource = Get-ChildItem -path "${env:ProgramFiles(x86)}\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName | ||
| } | ||
|
|
||
| # Don't search the chocolatey program data until more official locations have been searched | ||
| if(!$exeSource) | ||
| { | ||
| Write-Verbose "Falling back to chocolatey..." -Verbose | ||
| $exeSource = Get-ChildItem -path "$env:ProgramData\chocolatey\$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName | ||
| } | ||
|
|
||
| # all obvious locations are exhausted, use brute force and search from the root of the filesystem | ||
| if(!$exeSource) | ||
| { | ||
| Write-Verbose "Falling back to the root of the drive..." -Verbose | ||
| $exeSource = Get-ChildItem -path "/$Executable" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName | ||
| } | ||
|
|
||
| if(!$exeSource) | ||
| { | ||
| throw "$Executable not found" | ||
| } | ||
|
|
||
| $exePath = Split-Path -Path $exeSource | ||
| Append-Path -path $exePath | ||
| } | ||
|
|
||
| if($Cleanup.IsPresent) | ||
| { | ||
| Remove-Folder -Folder "$env:temp\chocolatey" | ||
| } | ||
| } | ||
|
|
||
| function Append-Path | ||
| { | ||
| param | ||
| ( | ||
| $path | ||
| ) | ||
| $machinePathString = [System.Environment]::GetEnvironmentVariable('path',[System.EnvironmentVariableTarget]::Machine) | ||
| $machinePath = $machinePathString -split ';' | ||
|
|
||
| if($machinePath -inotcontains $path) | ||
| { | ||
| $newPath = "$machinePathString;$path" | ||
| Write-Verbose "Adding $path to path..." -Verbose | ||
| [System.Environment]::SetEnvironmentVariable('path',$newPath,[System.EnvironmentVariableTarget]::Machine) | ||
| Write-Verbose "Added $path to path." -Verbose | ||
| } | ||
| else | ||
| { | ||
| Write-Verbose "$path already in path." -Verbose | ||
| } | ||
| } | ||
|
|
||
| function Remove-Folder | ||
| { | ||
| param( | ||
| [string] | ||
| $Folder | ||
| ) | ||
|
|
||
| Write-Verbose "Cleaning up $Folder..." -Verbose | ||
| $filter = Join-Path -Path $Folder -ChildPath * | ||
| [int]$measuredCleanupMB = (Get-ChildItem $filter -Recurse | Measure-Object -Property Length -Sum).Sum / 1MB | ||
| Remove-Item -recurse -force $filter -ErrorAction SilentlyContinue | ||
| Write-Verbose "Cleaned up $measuredCleanupMB MB from $Folder" -Verbose | ||
| } |
22 changes: 22 additions & 0 deletions
22
tools/releaseBuild/Images/microsoft_powershell_windowsservercore/wix.psm1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| Import-Module "$PSScriptRoot\dockerInstall.psm1" | ||
|
|
||
| # Install using Wix Zip because the MSI requires an older version of dotnet | ||
| # which was large and unstable in docker | ||
| function Install-WixZip | ||
| { | ||
| param($zipPath) | ||
|
|
||
| $targetRoot = "${env:ProgramFiles(x86)}\WiX Toolset xcopy" | ||
| $binPath = Join-Path -Path $targetRoot -ChildPath 'bin' | ||
| Write-Verbose "Expanding $zipPath to $binPath ..." -Verbose | ||
| Expand-Archive -Path $zipPath -DestinationPath $binPath -Force | ||
| $docExpandPath = Join-Path -Path $binPath -ChildPath 'doc' | ||
| $sdkExpandPath = Join-Path -Path $binPath -ChildPath 'sdk' | ||
| $docTargetPath = Join-Path -Path $targetRoot -ChildPath 'doc' | ||
| $sdkTargetPath = Join-Path -Path $targetRoot -ChildPath 'sdk' | ||
| Write-Verbose "Fixing folder structure ..." -Verbose | ||
| Move-Item -Path $docExpandPath -Destination $docTargetPath | ||
| Move-Item -Path $sdkExpandPath -Destination $sdkTargetPath | ||
| Append-Path -path $binPath | ||
| Write-Verbose "Done installing WIX!" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please exclude this change from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sorry this is a change that is needed. Saw it in reverse when I talked to you.