Created
March 8, 2017 17:06
-
-
Save BatslyAdams/56a8bc9b57ed85ae22917f6563d7ff62 to your computer and use it in GitHub Desktop.
Java environment in Windows Server Core setup using PowerShell - DevOps Hackathon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Starting Dockerfile for a Java based project in Windows Server Core with JDK integrity check | |
FROM microsoft/windowsservercore | |
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] | |
WORKDIR c:/setup | |
# Set variables for OpenJDK pull | |
ENV JAVA_VERSION="1.8.0.111-3" ` | |
JAVA_ZIP_VERSION="1.8.0-openjdk-1.8.0.111-3.b15" ` | |
JAVA_SHA256="e080371bf57536668416157660e05d95fe04db15da36234d32bda8e301bb0454" ` | |
JAVA_HOME="C:\openjdk" | |
# wget equivalent with additional steps for integrity | |
RUN Invoke-WebRequest $('https://github.com/ojdkbuild/ojdkbuild/releases/download/{0}/java-{1}.ojdkbuild.windows.x86_64.zip' -f $env:JAVA_VERSION, $env:JAVA_ZIP_VERSION) -OutFile 'openjdk.zip' -UseBasicParsing ; ` | |
if ((Get-FileHash openjdk.zip -Algorithm sha256).Hash -ne $env:JAVA_SHA256) {exit 1} ; ` | |
Expand-Archive openjdk.zip -DestinationPath C:\ ; ` | |
mv "C:\java-$($env:JAVA_ZIP_VERSION).ojdkbuild.windows.x86_64" 'c:\openjdk'; | |
$env:PATH = '{0}\bin;{1}' -f $env:JAVA_HOME, $env:PATH ; ` | |
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine) ; ` | |
Remove-Item -Path openjdk.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment