-
Notifications
You must be signed in to change notification settings - Fork 8.1k
update docker file for nanoserver 1709 release #5252
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,32 @@ | ||
| # escape=` | ||
| FROM microsoft/nanoserver:latest | ||
| # Args used by from statements must be defined here: | ||
| ARG NanoServerVersion=1709 | ||
| ARG WindowsServerCoreVersion=latest | ||
| ARG WindowsServerCoreRepo=microsoft/windowsservercore | ||
| ARG NanoServerRepo=microsoft/nanoserver | ||
|
|
||
| ARG POWERSHELL_ZIP=https://github.com/PowerShell/PowerShell/releases/download/v6.0.0-beta.9/PowerShell-6.0.0-beta.9-win-x64.zip | ||
| ARG POWERSHELL_VERSION=6.0.0-beta.9 | ||
| ARG IMAGE_NAME=microsoft/powershell:nanoserver | ||
| # Use server core as an installer container to extract PowerShell, | ||
| # As this is a multi-stage build, this stage will eventually be thrown away | ||
| FROM ${WindowsServerCoreRepo}:$WindowsServerCoreVersion AS installer-env | ||
|
|
||
| # Arguments for installing powershell, must be defined in the container they are used | ||
| ARG PS_VERSION=6.0.0-beta.9 | ||
|
|
||
| ENV PS_DOWNLOAD_URL https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip | ||
|
|
||
| SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] | ||
|
|
||
| RUN if (!($env:PS_VERSION -match '^\d+\.\d+\.\d+(-\w+\.\d+)?$' )) {throw ('PS_Version ({0}) must match the regex "^\d+\.\d+\.\d+(-\w+\.\d+)?$"' -f $env:PS_VERSION)} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line was added |
||
| RUN Invoke-WebRequest $Env:PS_DOWNLOAD_URL -OutFile powershell.zip | ||
|
|
||
| RUN Expand-Archive powershell.zip -DestinationPath \PowerShell | ||
|
|
||
| # Install PowerShell into NanoServer | ||
| FROM ${NanoServerRepo}:$NanoServerVersion | ||
|
|
||
| ARG VCS_REF="none" | ||
| ARG PS_VERSION=6.0.0-beta.9 | ||
| ARG IMAGE_NAME=microsoft/powershell | ||
|
|
||
| LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" ` | ||
| readme.md="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" ` | ||
|
|
@@ -12,50 +35,23 @@ LABEL maintainer="PowerShell Team <powershellteam@hotmail.com>" ` | |
| org.label-schema.url="https://github.com/PowerShell/PowerShell/blob/master/docker/README.md" ` | ||
| org.label-schema.vcs-url="https://github.com/PowerShell/PowerShell" ` | ||
| org.label-schema.name="powershell" ` | ||
| org.label-schema.vcs-ref=${VCS_REF} ` | ||
| org.label-schema.vendor="PowerShell" ` | ||
| org.label-schema.version=${POWERSHELL_VERSION} ` | ||
| org.label-schema.version=${PS_VERSION} ` | ||
| org.label-schema.schema-version="1.0" ` | ||
| org.label-schema.docker.cmd="docker run ${IMAGE_NAME} pwsh -c '$psversiontable'" ` | ||
| org.label-schema.docker.cmd.devel="docker run ${IMAGE_NAME}" ` | ||
| org.label-schema.docker.cmd.test="docker run ${IMAGE_NAME} pwsh -c Invoke-Pester" ` | ||
| org.label-schema.docker.cmd.help="docker run ${IMAGE_NAME} pwsh -c Get-Help" | ||
|
|
||
| # TODO: addd LABEL org.label-schema.vcs-ref=${VCS_REF} | ||
|
|
||
| RUN setx /M PATH "%ProgramFiles%\PowerShell\latest;%PATH%" | ||
| # Setup PowerShell - Log-to > C:\Docker.log | ||
| SHELL ["C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"] | ||
| ADD $POWERSHELL_ZIP /powershell-win-x64.zip | ||
|
|
||
| # Install PowerShell package and clean up | ||
| RUN $ErrorActionPreference='Stop'; ` | ||
| $ConfirmPreference='None'; ` | ||
| $VerbosePreference='Continue'; ` | ||
| Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; ` | ||
| $PSVersionTable | Write-Output ; ` | ||
| $VerInfo = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' ; ` | ||
| ('FullBuildString: '+$VerInfo.BuildLabEx) | Write-Output ; ` | ||
| ('OperatingSystem: '+$VerInfo.ProductName+' '+$VerInfo.EditionId+' '+$VerInfo.InstallationType) | Write-Output ; ` | ||
| [System.IO.FileInfo]$ZipFile = Get-Item -Path ./powershell-win-x64.zip ; ` | ||
| New-Item -Path $Env:ProgramFiles/PowerShell -ItemType Directory -Force | out-null ; ` | ||
| [System.IO.DirectoryInfo]$PsFolder=New-Item -Path $Env:ProgramFiles\PowerShell -ItemType Directory -Force ; ` | ||
| Add-Type -AssemblyName System.IO.Compression.ZipFile ; ` | ||
| [System.IO.Compression.ZipFile]::ExtractToDirectory($ZipFile,$PsFolder) ; ` | ||
| if (Get-ChildItem -Path $PsFolder/pwsh.exe) { ` | ||
| Remove-Item -Path $ZipFile ; ` | ||
| New-Item -Type SymbolicLink -Path $PsFolder\ -Name latest -Value $PsFolder ` | ||
| } else { throw 'Installation failed! See c:\Dockerfile.log' } ; | ||
|
|
||
| # Verify New pwsh.exe runs | ||
| SHELL ["C:\\Program Files\\PowerShell\\latest\\pwsh.exe", "-command"] | ||
| RUN Start-Transcript -path C:\Dockerfile.log -append -IncludeInvocationHeader ; ` | ||
| $ErrorActionPreference='Stop'; ` | ||
| Write-Output $PSVersionTable ; ` | ||
| If (-not($PSVersionTable.PSEdition -Match 'Core')) { ` | ||
| Throw [String]$('['+$PSVersionTable.PSEdition+'] is not [Core]!') ; ` | ||
| } ; | ||
| # Copy Powershell Core from the installer containter | ||
| ENV ProgramFiles C:\Program Files | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are quotes needed here around c:\Program Files? A bigger question that I don't quite understand: Why are you defining it here and not using $env:ProgramFiles or %ProgramFiles%?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this is a tested an working file.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are only two changes to the file. I added comments for the two changes. The file which was deleted, otherwise replaced the older file.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about my second question? I added it a little later via edit
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docker itself cannot use the container environment variables. This is used in docker commands. |
||
| COPY --from=installer-env ["\\PowerShell\\", "$ProgramFiles\\PowerShell"] | ||
|
|
||
| # Persist %PSCORE% ENV variable for user convenience | ||
| ENV PSCORE='"C:\Program Files\PowerShell\latest\pwsh.exe"' | ||
| ENV PSCORE="$ProgramFiles\PowerShell\pwsh.exe" | ||
|
|
||
| # Set the path | ||
| RUN setx PATH "%PATH%;%ProgramFiles%\PowerShell" | ||
|
|
||
| CMD ["pwsh.exe"] | ||
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.
the values for these first arguments changed