Skip to content

Commit b4989a0

Browse files
[SHIR] Install Microsoft JDK and then delete msi to decrease image size (#17)
* [SHIR] Support installing Microsoft JDK during build docker image as needed * [SHIR] Remove SHIR msi in the docker image to decrease image size
1 parent 0ac4ee4 commit b4989a0

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
FROM mcr.microsoft.com/windows/servercore:ltsc2019
2+
ARG INSTALL_JDK=false
23

34
# Download the latest self-hosted integration runtime installer into the SHIR folder
45
COPY SHIR C:/SHIR/

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ For more information about Azure Data Factory, see [https://docs.microsoft.com/e
99
# QuickStart
1010
1. Prepare [Windows for containers](https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/set-up-environment?tabs=dockerce)
1111
2. Build the Windows container image in the project folder
12-
```bash
13-
> docker build . -t <image-name>
12+
```bash
13+
> docker build . -t <image-name> [--build-arg="INSTALL_JDK=true"]
1414
```
15+
### __Arguments list__
16+
|Name|Necessity|Default|Description|
17+
|---|---|---|---|
18+
| `INSTALL_JDK` | Optional | `false` | The flag to install Microsoft's JDK 11 LTS. |
1519
3. Run the container with specific arguments by passing environment variables
1620
```bash
1721
> docker run -d -e AUTH_KEY=<ir-authentication-key> \

SHIR/build.ps1

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ function Install-SHIR() {
3030
}
3131

3232
Write-Log "SHIR MSI Install Successfully"
33+
Write-Log "Will remove C:\SHIR\$MsiFileName"
34+
Remove-Item "C:\SHIR\$MsiFileName"
35+
Write-Log "Removed C:\SHIR\$MsiFileName"
36+
}
37+
38+
function Install-MSFT-JDK() {
39+
Write-Log "Install the Microsoft OpenJDK in the Windows container"
40+
41+
Write-Log "Downloading Microsoft OpenJDK 11 LTS msi"
42+
$JDKMsiFileName = 'microsoft-jdk-11-windows-x64.msi'
43+
44+
# 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)
45+
$ProgressPreference = 'SilentlyContinue'
46+
Invoke-WebRequest -Uri "https://aka.ms/download-jdk/$JDKMsiFileName" -OutFile "C:\SHIR\$JDKMsiFileName"
47+
$ProgressPreference = 'Continue'
48+
49+
Write-Log "Installing Microsoft OpenJDK"
50+
# Arguments pulled from https://learn.microsoft.com/en-us/java/openjdk/install#install-via-msi
51+
Start-Process msiexec.exe -Wait -ArgumentList "/i C:\SHIR\$JDKMsiFileName ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome INSTALLDIR=`"c:\Program Files\Microsoft\`" /quiet"
52+
if (!$?) {
53+
Write-Log "Microsoft OpenJDK MSI Install Failed"
54+
}
55+
Write-Log "Microsoft OpenJDK MSI Install Successfully"
56+
Write-Log "Will remove C:\SHIR\$JDKMsiFileName"
57+
Remove-Item "C:\SHIR\$JDKMsiFileName"
58+
Write-Log "Removed C:\SHIR\$JDKMsiFileName"
3359
}
3460

3561
function SetupEnv() {
@@ -39,5 +65,8 @@ function SetupEnv() {
3965
}
4066

4167
Install-SHIR
68+
if ([bool]::Parse($env:INSTALL_JDK)) {
69+
Install-MSFT-JDK
70+
}
4271

4372
exit 0

0 commit comments

Comments
 (0)