From 7a1ec129775dce36c4186a960776cee9bd8e3033 Mon Sep 17 00:00:00 2001 From: Ricardo Rosales <728243+missingcharacter@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:47:11 -0500 Subject: [PATCH 1/2] [SHIR] Install Microsoft JDK and then delete msi to decrease image size [SHIR] Remove SHIR msi to decrease image size --- Dockerfile | 1 + SHIR/build.ps1 | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) 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/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 From 0b8c59e86fb7f58b457fe50683a5be1743c70322 Mon Sep 17 00:00:00 2001 From: Ricardo Rosales <728243+missingcharacter@users.noreply.github.com> Date: Fri, 8 Sep 2023 10:05:22 -0500 Subject: [PATCH 2/2] [SHIR] Install Microsoft JDK and then delete msi to decrease image size [SHIR] Remove SHIR msi to decrease image size --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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= \