|
| 1 | +FROM microsoft/nanoserver |
| 2 | + |
| 3 | +ENV NPM_CONFIG_LOGLEVEL info |
| 4 | +ENV NODE_VERSION 4.5.0 |
| 5 | +ENV NODE_SHA256 16aab15b29e79746d1bae708f6a5dbed8ef3c87426a9408f7261163d0cda0f56 |
| 6 | + |
| 7 | +RUN powershell.exe -Command \ |
| 8 | + $ErrorActionPreference = 'Stop' ; \ |
| 9 | + $handler = New-Object System.Net.Http.HttpClientHandler ; \ |
| 10 | + $client = New-Object System.Net.Http.HttpClient($handler) ; \ |
| 11 | + $client.Timeout = New-Object System.TimeSpan(0, 30, 0) ; \ |
| 12 | + $cancelTokenSource = [System.Threading.CancellationTokenSource]::new() ; \ |
| 13 | + $responseMsg = $client.GetAsync([System.Uri]::new('https://nodejs.org/dist/v%NODE_VERSION%/node-v%NODE_VERSION%-win-x64.zip'), $cancelTokenSource.Token) ; \ |
| 14 | + $responseMsg.Wait() ; \ |
| 15 | + $downloadedFileStream = [System.IO.FileStream]::new('C:\node.zip', [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write) ; \ |
| 16 | + $response = $responseMsg.Result ; \ |
| 17 | + $copyStreamOp = $response.Content.CopyToAsync($downloadedFileStream) ; \ |
| 18 | + $copyStreamOp.Wait() ; \ |
| 19 | + $downloadedFileStream.Close() ; \ |
| 20 | + [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\node.zip','c:\') ; \ |
| 21 | + Rename-Item 'C:\node-v%NODE_VERSION%-win-x64' 'C:\nodejs' ; \ |
| 22 | + New-Item '%APPDATA%\npm' ; \ |
| 23 | + $env:PATH = 'C:\nodejs;%APPDATA%\npm;' + $env:PATH ; \ |
| 24 | + Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $env:PATH ; \ |
| 25 | + Remove-Item -Path node.zip |
| 26 | + |
| 27 | +CMD [ "node.exe" ] |
0 commit comments