|
| 1 | +FROM microsoft/nanoserver:sac2016 |
| 2 | + |
| 3 | +# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324 |
| 4 | +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] |
| 5 | + |
| 6 | +# enable TLS 1.2 (Nano Server doesn't support using "[Net.ServicePointManager]::SecurityProtocol") |
| 7 | +# https://docs.microsoft.com/en-us/system-center/vmm/install-tls?view=sc-vmm-1801 |
| 8 | +# https://docs.microsoft.com/en-us/windows-server/identity/ad-fs/operations/manage-ssl-protocols-in-ad-fs#enable-tls-12 |
| 9 | +RUN Write-Host 'Enabling TLS 1.2 (https://githubengineering.com/crypto-removal-notice/) ...'; \ |
| 10 | + $tls12RegBase = 'HKLM:\\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2'; \ |
| 11 | + if (Test-Path $tls12RegBase) { throw ('"{0}" already exists!' -f $tls12RegBase) }; \ |
| 12 | + New-Item -Path ('{0}/Client' -f $tls12RegBase) -Force; \ |
| 13 | + New-Item -Path ('{0}/Server' -f $tls12RegBase) -Force; \ |
| 14 | + New-ItemProperty -Path ('{0}/Client' -f $tls12RegBase) -Name 'DisabledByDefault' -PropertyType DWORD -Value 0 -Force; \ |
| 15 | + New-ItemProperty -Path ('{0}/Client' -f $tls12RegBase) -Name 'Enabled' -PropertyType DWORD -Value 1 -Force; \ |
| 16 | + New-ItemProperty -Path ('{0}/Server' -f $tls12RegBase) -Name 'DisabledByDefault' -PropertyType DWORD -Value 0 -Force; \ |
| 17 | + New-ItemProperty -Path ('{0}/Server' -f $tls12RegBase) -Name 'Enabled' -PropertyType DWORD -Value 1 -Force |
| 18 | + |
| 19 | +ENV JAVA_HOME C:\\ojdkbuild |
| 20 | +RUN $newPath = ('{0}\bin;{1}' -f $env:JAVA_HOME, $env:PATH); \ |
| 21 | + Write-Host ('Updating PATH: {0}' -f $newPath); \ |
| 22 | +# Nano Server does not have "[Environment]::SetEnvironmentVariable()" |
| 23 | + setx /M PATH $newPath; |
| 24 | + |
| 25 | +# https://github.com/ojdkbuild/ojdkbuild/releases |
| 26 | +ENV JAVA_VERSION 10.0.1 |
| 27 | +ENV JAVA_OJDKBUILD_VERSION 10.0.1-1 |
| 28 | +ENV JAVA_OJDKBUILD_ZIP java-10-openjdk-10.0.1-1.b10.ojdkbuild.windows.x86_64.zip |
| 29 | +ENV JAVA_OJDKBUILD_SHA256 64664f2e28db55022d90beefd097779c59f843cacf1afeed8a7456ee64c603f1 |
| 30 | + |
| 31 | +RUN $url = ('https://github.com/ojdkbuild/ojdkbuild/releases/download/{0}/{1}' -f $env:JAVA_OJDKBUILD_VERSION, $env:JAVA_OJDKBUILD_ZIP); \ |
| 32 | + Write-Host ('Downloading {0} ...' -f $url); \ |
| 33 | + Invoke-WebRequest -Uri $url -OutFile 'ojdkbuild.zip'; \ |
| 34 | + Write-Host ('Verifying sha256 ({0}) ...' -f $env:JAVA_OJDKBUILD_SHA256); \ |
| 35 | + if ((Get-FileHash ojdkbuild.zip -Algorithm sha256).Hash -ne $env:JAVA_OJDKBUILD_SHA256) { \ |
| 36 | + Write-Host 'FAILED!'; \ |
| 37 | + exit 1; \ |
| 38 | + }; \ |
| 39 | + \ |
| 40 | + Write-Host 'Expanding ...'; \ |
| 41 | + Expand-Archive ojdkbuild.zip -DestinationPath C:\; \ |
| 42 | + \ |
| 43 | + Write-Host 'Renaming ...'; \ |
| 44 | + Move-Item \ |
| 45 | + -Path ('C:\{0}' -f ($env:JAVA_OJDKBUILD_ZIP -Replace '.zip$', '')) \ |
| 46 | + -Destination $env:JAVA_HOME \ |
| 47 | + ; \ |
| 48 | + \ |
| 49 | + Write-Host 'Verifying install ...'; \ |
| 50 | + Write-Host ' java -version'; java -version; \ |
| 51 | + Write-Host ' javac -version'; javac -version; \ |
| 52 | + \ |
| 53 | + Write-Host 'Removing ...'; \ |
| 54 | + Remove-Item ojdkbuild.zip -Force; \ |
| 55 | + \ |
| 56 | + Write-Host 'Complete.'; |
0 commit comments