Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SHIR] Install Microsoft JDK and then delete msi to decrease image size #17

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <image-name>
```bash
> docker build . -t <image-name> [--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=<ir-authentication-key> \
Expand Down
29 changes: 29 additions & 0 deletions SHIR/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -39,5 +65,8 @@ function SetupEnv() {
}

Install-SHIR
if ([bool]::Parse($env:INSTALL_JDK)) {
Install-MSFT-JDK
}

exit 0