Images for your application
East India ships no Windows images. You prepare a root image once from Microsoft's Windows installation disc, then build your own layers on it: a tools layer with what every test needs, and an application layer with the software under test. A recipe for a layer is an Endiafile, a file in Dockerfile syntax.
The root image
endia base prepare installs Windows from the ISO in the image folder and makes the root image:
echo "$PASSWORD" | endia base prepare M:\eastindia\windows11-iot-ltsc-2024-eval-x64.iso --tag lab/win11:base --password-stdin
It takes about half an hour. The password must meet Windows' own password rules. Both accounts in the new Windows use it:
testuser, a standard account that signs in automatically at every start;testadmin, an administrator. Its name and password are what East India enters to answer an elevation prompt.
The root image holds Windows, East India's guest service and desktop helper, an OpenSSH server and curl.exe, and nothing else: your recipes install everything the test needs, .NET included. Building and layering images describes the command in full.
Windows Update is off in the root image. Every machine is short-lived, so updating Windows would only spend the machine's processor time, memory and network on work that is thrown away with it. Microsoft Defender still looks for its own updates, and its downloads fail.
It stops working 90 days after its root image was prepared. Each image records the date in its eastindia.evaluation.expires label, and endia images warns as that date approaches. The desktop shows the edition and its licence status as a watermark in the bottom-right corner, which appears in screenshots. On a machine's first boot the watermark wrongly says 'Windows License is expired'. Windows' licensing still counts the machine as licensed, and after a restart the watermark gives the days left. The wrong text does not affect tests.
The tools layer
The tools layer holds the runtimes your application needs and the Windows settings every test needs. This one installs the .NET runtime of channel 10.0 and its desktop runtime, and turns off the secure screen for elevation prompts, so that East India can answer them:
# escape=`
FROM lab/win11:base
SHELL ["powershell.exe", "-NoProfile", "-Command"]
WORKDIR C:\setup
COPY dotnet-install.ps1 .
RUN .\dotnet-install.ps1 -Channel 10.0 -Runtime dotnet -InstallDir 'C:\Program Files\dotnet'
RUN .\dotnet-install.ps1 -Channel 10.0 -Runtime windowsdesktop -InstallDir 'C:\Program Files\dotnet'
RUN [Environment]::SetEnvironmentVariable('Path', $env:Path + ';C:\Program Files\dotnet', 'Machine')
RUN reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v PromptOnSecureDesktop /t REG_DWORD /d 0 /f
endia build -t lab/tools:1 -f tools.Endiafile .
dotnet-install.ps1 is Microsoft's install script, from https://dot.net/v1/dotnet-install.ps1, kept in the build context. The desktop runtime needs the base runtime, which brings dotnet.exe, so the base runtime is installed first.
The last line matters for desktop tests. Windows normally shows an elevation prompt on a separate secure screen, where only Windows itself can read and press it. With PromptOnSecureDesktop set to 0, the prompt appears on the normal desktop, where desktop uac answers it. Without the setting, desktop uac fails with CAPABILITY_MISSING and says so. endia inspect <machine> reports uacPromptAutomation: true when the setting is in place.
The application layer
The application layer installs your application and the Windows settings it needs on top of the tools layer. This one installs a Windows service that starts with Windows and opens its port in the Windows firewall:
# escape=`
FROM lab/tools:1
SHELL ["powershell.exe", "-NoProfile", "-Command"]
COPY SampleService/ C:/apps/SampleService/
RUN New-Service -Name SampleService -BinaryPathName 'C:\apps\SampleService\SampleService.exe' -StartupType Automatic | Out-Null
RUN New-NetFirewallRule -DisplayName SampleService -Direction Inbound -Action Allow -Protocol TCP -LocalPort 8080 | Out-Null
endia build -t sample/server:1 -f server.Endiafile ./publish
The last argument, ./publish, is the build context: the folder whose files COPY reads. The command line sends that folder to the service with the request. The build prints Docker's classic output, Step n/m : ..., and ends with Successfully tagged sample/server:1. Building this recipe took 29 seconds. Building the same recipe with the same inputs again reuses the image (Using cache:); --no-cache builds it afresh.
Recipe rules
- File names. A recipe's file is
Endiafile, orname.Endiafilewhen a folder holds several. Without-f,endia buildreadsEndiafilein the build context, orDockerfilewhen there is noEndiafile;-ftakes a file of any name, so a recipe kept asname.Dockerfilestill builds. - Ignore files.
.endiaignore, or failing that.dockerignore, lists the files that a build leaves out of the context. A recipe can have its own beside it, such asserver.Endiafile.endiaignore, which comes first. - Steps.
RUNsteps run as SYSTEM, can reach the internet, and may take up to 30 minutes each. A step that exits with 3010 restarts the machine and the build carries on. - Shells.
SHELL ["powershell.exe", ...]is Windows PowerShell 5.1. WithoutSHELL, a step runs throughcmd /S /C. - Refused.
ADD,VOLUME,HEALTHCHECK, here-documents and options onCOPYandRUNare refused withUNSUPPORTED_FIELD, naming the line. - Layers. Docker caches each instruction; East India makes one layer per stage. Any change to a stage rebuilds all of it, so slow steps belong in an early stage, which is why the tools and the application are separate recipes.
VS Code recognises Dockerfile by name but not Endiafile. To give Endiafiles Dockerfile highlighting, add this to your settings (File › Preferences › Settings, then the Open Settings (JSON) button):
"files.associations": {
"Endiafile": "dockerfile",
"*.Endiafile": "dockerfile"
}
Baking versus copying
Bake into an image what every run needs and what changes rarely: runtimes, the service's installation, firewall rules, registry settings. Copy into a running machine what changes on every run, such as the build under test (see Creating and starting machines). A machine starts from an image in about 20 seconds; installing software into every machine on every run costs that time again each run.