Nano server with Dotnet SDK, PowerShell, Python and Azure Cli
1.1K
FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1803 AS base
FROM microsoft/windowsservercore:1709 AS azcli
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ENV PYTHON_VERSION 3.6.5 ENV DESTINATION_FOLDER C:\tools
RUN $python_url = ('https://www.python.org/ftp/python/{0}/python-{0}-amd64.exe' -f $env:PYTHON_VERSION);
Write-Host ('Downloading {0}...' -f $python_url);
mkdir tmp > $null;
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
(New-Object System.Net.WebClient).DownloadFile($python_url, 'c:\tmp\python-installer.exe'); \
$install_folder = Join-Path -Path $env:DESTINATION_FOLDER -ChildPath 'python';
Write-Host ('Installing into {0}...' -f $install_folder);
Start-Process c:\tmp\python-installer.exe -Wait -ArgumentList @('/quiet', 'InstallAllUsers=1', 'TargetDir={0}' -f $install_folder, 'PrependPath=1', 'Shortcuts=0', 'Include_doc=0','Include_pip=1', 'Include_test=0');
Remove-Item tmp -Recurse -Force;
FROM mcr.microsoft.com/powershell:nanoserver AS installer-env Arguments for installing PowerShell, must be defined in the container they are used ARG PS_VERSION=6.2.0
ARG PS_PACKAGE_URL=https://github.com/PowerShell/PowerShell/releases/download/v$PS_VERSION/PowerShell-$PS_VERSION-win-x64.zip
ARG PS_PACKAGE_URL_BASE64
RUN Write-host "Verifying valid Version...";
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)
}
$ProgressPreference = 'SilentlyContinue';
if($env:PS_PACKAGE_URL_BASE64){
Write-host "decoding: $env:PS_PACKAGE_URL_BASE64" ;
$url = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($env:PS_PACKAGE_URL_BASE64))
} else {
Write-host "using url: $env:PS_PACKAGE_URL" ;
$url = $env:PS_PACKAGE_URL
}
Write-host "downloading: $url";
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12;
New-Item -ItemType Directory /installer > $null ;
Invoke-WebRequest -Uri $url -outfile /installer/powershell.zip -verbose;
Expand-Archive /installer/powershell.zip -DestinationPath \PowerShell
FROM microsoft/dotnet:2.1-sdk-nanoserver-1803 AS build
RUN mkdir dotnetsdk RUN xcopy "c:\Program Files\dotnet*.*" "c:\dotnetsdk" /s /e
FROM base AS final
WORKDIR /Program Files/dotnet COPY --from=build /dotnetsdk .
WORKDIR /Program Files/PowerShell COPY --from=installer-env /PowerShell .
RUN setx PATH "%PATH%;%ProgramFiles%\PowerShell";
Installing AzureCli in NanoServer WORKDIR / COPY --from=azcli ["tools", "tools"]
USER ContainerAdministrator RUN setx /M PATH "%PATH%;c:\tools\python;c:\tools\python\Scripts";
WORKDIR /azure-cli USER ContainerUser RUN python -m pip install --upgrade pip RUN pip install wheel RUN pip install azure-cli
SHELL ["cmd", "/S", "/C"]
Content type
Image
Digest
Size
824.3 MB
Last updated
about 7 years ago
docker pull jparientehiberus/full.windows.nanoserver