Skip to content

Commit 12d49db

Browse files
[GitHub Actions] Added support for building and pushing container image to ghcr.io
[SHIR] Install Microsoft JDK and then delete msi to decrease image size [SHIR] Remove SHIR msi to decrease image size
1 parent 0ac4ee4 commit 12d49db

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Docker image
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
10+
11+
jobs:
12+
build:
13+
permissions: write-all
14+
runs-on: windows-2022
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Generate image tag
18+
shell: bash
19+
id: gen-image-tag
20+
run: |
21+
if [ "${{ github.event_name }}" == "pull_request" ]; then
22+
ref=PR-${{ github.event.number }}
23+
# NOTE: we tag images with the head commit so they can be easily tagged/deployed,
24+
# but on pull requests the image is actually built with the merge commit
25+
head_commit=${{ github.event.pull_request.head.sha }}
26+
else
27+
ref=${{ github.ref_name }}
28+
head_commit=${{ github.sha }}
29+
fi
30+
# for PRs: PR-11850.37.e7426df
31+
# for push (develop/main/master): master.37.e7426df
32+
echo "image_tag=${ref}.${{ github.run_number }}.$(echo ${head_commit} | cut -c1-7)" >> $GITHUB_OUTPUT
33+
- uses: mr-smithers-excellent/docker-build-push@v6
34+
with:
35+
image: adf-shir
36+
tags: ${{ steps.gen-image-tag.outputs.image_tag }}
37+
registry: ghcr.io
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/windows/servercore:ltsc2019
1+
FROM mcr.microsoft.com/windows/servercore:ltsc2022
22

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

SHIR/build.ps1

Lines changed: 27 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,6 @@ function SetupEnv() {
3965
}
4066

4167
Install-SHIR
68+
Install-MSFT-JDK
4269

4370
exit 0

0 commit comments

Comments
 (0)