|
| 1 | +FROM microsoft/windowsservercore:ltsc2016 |
| 2 | + |
| 3 | +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 |
| 4 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
| 5 | + |
| 6 | +ENV JAVA_HOME C:\\jdk-12 |
| 7 | +RUN $newPath = ('{0}\bin;{1}' -f $env:JAVA_HOME, $env:PATH); \ |
| 8 | + Write-Host ('Updating PATH: {0}' -f $newPath); \ |
| 9 | +# Nano Server does not have "[Environment]::SetEnvironmentVariable()" |
| 10 | + setx /M PATH $newPath |
| 11 | + |
| 12 | +# http://jdk.java.net/ |
| 13 | +ENV JAVA_VERSION 12-ea+9 |
| 14 | +ENV JAVA_URL https://download.java.net/java/early_access/jdk12/9/GPL/openjdk-12-ea+9_windows-x64_bin.zip |
| 15 | +ENV JAVA_SHA256 49eb49f808d2beff6c977f2f60aa75f17c8adbb3280bea482816aa6a083b0952 |
| 16 | + |
| 17 | +RUN Write-Host ('Downloading {0} ...' -f $env:JAVA_URL); \ |
| 18 | + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ |
| 19 | + Invoke-WebRequest -Uri $env:JAVA_URL -OutFile 'openjdk.zip'; \ |
| 20 | + Write-Host ('Verifying sha256 ({0}) ...' -f $env:JAVA_SHA256); \ |
| 21 | + if ((Get-FileHash openjdk.zip -Algorithm sha256).Hash -ne $env:JAVA_SHA256) { \ |
| 22 | + Write-Host 'FAILED!'; \ |
| 23 | + exit 1; \ |
| 24 | + }; \ |
| 25 | + \ |
| 26 | + Write-Host 'Expanding ...'; \ |
| 27 | + Expand-Archive openjdk.zip -DestinationPath C:\; \ |
| 28 | + \ |
| 29 | + Write-Host 'Verifying install ...'; \ |
| 30 | + Write-Host ' java -version'; java -version; \ |
| 31 | + Write-Host ' javac -version'; javac -version; \ |
| 32 | + \ |
| 33 | + Write-Host 'Removing ...'; \ |
| 34 | + Remove-Item openjdk.zip -Force; \ |
| 35 | + \ |
| 36 | + Write-Host 'Complete.' |
| 37 | + |
| 38 | +# https://docs.oracle.com/javase/10/tools/jshell.htm |
| 39 | +# https://en.wikipedia.org/wiki/JShell |
| 40 | +CMD ["jshell"] |
0 commit comments