diff --git a/Dockerfile b/Dockerfile index af447d9..d5c4910 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2019 +ARG INSTALL_JDK=false # Download the latest self-hosted integration runtime installer into the SHIR folder COPY SHIR C:/SHIR/ diff --git a/README.md b/README.md index c4ac2c7..8814733 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,13 @@ For more information about Azure Data Factory, see [https://docs.microsoft.com/e # QuickStart 1. Prepare [Windows for containers](https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce) 2. Build the Windows container image in the project folder -```bash -> docker build . -t +```bash +> docker build . -t [--build-arg="INSTALL_JDK=true"] ``` +### __Arguments list__ +|Name|Necessity|Default|Description| +|---|---|---|---| +| `INSTALL_JDK` | Optional | `false` | The flag to install Microsoft's JDK 11 LTS. | 3. Run the container with specific arguments by passing environment variables ```bash > docker run -d -e AUTH_KEY= \ diff --git a/SHIR/build.ps1 b/SHIR/build.ps1 index a278842..4b4a8fd 100644 --- a/SHIR/build.ps1 +++ b/SHIR/build.ps1 @@ -30,6 +30,32 @@ function Install-SHIR() { } Write-Log "SHIR MSI Install Successfully" + Write-Log "Will remove C:\SHIR\$MsiFileName" + Remove-Item "C:\SHIR\$MsiFileName" + Write-Log "Removed C:\SHIR\$MsiFileName" +} + +function Install-MSFT-JDK() { + Write-Log "Install the Microsoft OpenJDK in the Windows container" + + Write-Log "Downloading Microsoft OpenJDK 11 LTS msi" + $JDKMsiFileName = 'microsoft-jdk-11-windows-x64.msi' + + # Temporarily disable progress updates to speed up the download process. (See https://stackoverflow.com/questions/69942663/invoke-webrequest-progress-becomes-irresponsive-paused-while-downloading-the-fil) + $ProgressPreference = 'SilentlyContinue' + Invoke-WebRequest -Uri "https://aka.ms/download-jdk/$JDKMsiFileName" -OutFile "C:\SHIR\$JDKMsiFileName" + $ProgressPreference = 'Continue' + + Write-Log "Installing Microsoft OpenJDK" + # Arguments pulled from https://learn.microsoft.com/en-us/java/openjdk/install#install-via-msi + Start-Process msiexec.exe -Wait -ArgumentList "/i C:\SHIR\$JDKMsiFileName ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome INSTALLDIR=`"c:\Program Files\Microsoft\`" /quiet" + if (!$?) { + Write-Log "Microsoft OpenJDK MSI Install Failed" + } + Write-Log "Microsoft OpenJDK MSI Install Successfully" + Write-Log "Will remove C:\SHIR\$JDKMsiFileName" + Remove-Item "C:\SHIR\$JDKMsiFileName" + Write-Log "Removed C:\SHIR\$JDKMsiFileName" } function SetupEnv() { @@ -39,5 +65,8 @@ function SetupEnv() { } Install-SHIR +if ([bool]::Parse($env:INSTALL_JDK)) { + Install-MSFT-JDK +} exit 0