From ae939ce7f42490619a10f0a20b9fd7c60bb8a782 Mon Sep 17 00:00:00 2001 From: Anthony Nandaa Date: Wed, 31 Jul 2024 15:11:59 +0300 Subject: [PATCH] hack: dockerfiles: start off a nanoserver plus image the official mcr.microsoft.com/windows/nanoserver:ltsc2022 image does not ship with some binaries so as to reduce the image size. Some of those are needed for testing, etc. We are therefore creating a custom nanoserver aka nanoserver-plus image that ships with these binaries, and more others as needed Signed-off-by: Anthony Nandaa --- hacks/.gitignore | 1 + .../dockerfiles/nanoserver_plus/dockerfile | 12 ++++++++++++ .../nanoserver_plus/get_binaries.ps1 | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 hacks/scripts/dockerfiles/nanoserver_plus/dockerfile create mode 100644 hacks/scripts/dockerfiles/nanoserver_plus/get_binaries.ps1 diff --git a/hacks/.gitignore b/hacks/.gitignore index 7b0f5157..6be5c8bb 100644 --- a/hacks/.gitignore +++ b/hacks/.gitignore @@ -1 +1,2 @@ private/ +bin/ diff --git a/hacks/scripts/dockerfiles/nanoserver_plus/dockerfile b/hacks/scripts/dockerfiles/nanoserver_plus/dockerfile new file mode 100644 index 00000000..5286fb90 --- /dev/null +++ b/hacks/scripts/dockerfiles/nanoserver_plus/dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 + +# this is a minimal image based on nanoserver +# mainly for the purpose of testing, e.g. integration +# tests on moby/buildkit. + +# before building the image, run ./get_binaries.ps1 +# from the host. This dumps all the required binaries +# in the ./bin directory that is later moved to +# C:\Windows\system32 to be accessed within %PATH% + +COPY ./bin/* /Windows/System32/ diff --git a/hacks/scripts/dockerfiles/nanoserver_plus/get_binaries.ps1 b/hacks/scripts/dockerfiles/nanoserver_plus/get_binaries.ps1 new file mode 100644 index 00000000..e29fb303 --- /dev/null +++ b/hacks/scripts/dockerfiles/nanoserver_plus/get_binaries.ps1 @@ -0,0 +1,18 @@ + +# files to copy from Windows host. +# this are mainly legacy binaries that don't have any +# extra dependencies. +$filePaths = @( + "C:\Windows\System32\fc.exe", + "C:\Windows\System32\whoami.exe" +) + +$dest = "./bin" + +if (-not (Test-Path -Path $dest)) { + New-Item -ItemType Directory -Path $dest +} + +foreach ($filePath in $filePaths) { + Copy-Item -Path $filePath -Destination $dest +}