Skip to content

Commit 23bde16

Browse files
committed
Make Windows runner backend production ready
Add support for Windows Server Core 2019 and friends. - windows/servercore:ltsc2019 - windows/nanoserver:1809
1 parent fd3d4ff commit 23bde16

File tree

12 files changed

+403
-112
lines changed

12 files changed

+403
-112
lines changed

CHANGES.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ in progress
1111
- Improve platform guards and naming things
1212
- Improve central command invocation function
1313
- Improve documentation
14+
- Make Windows runner subsystem production ready.
15+
- Add support for Windows Server Core 2019 and friends, like
16+
``windows/servercore:ltsc2019``, ``windows/nanoserver:1809``, or
17+
``eclipse-temurin:17-jdk``.
1418

1519

1620
2022-05-20 0.2.0

README.rst

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,13 @@ another one for Windows.
109109
`systemd-nspawn`_. Provisioning of additional software is performed using the
110110
native package manager of the corresponding Linux distribution.
111111

112+
- For running Windows operating systems containers, Racker uses `Vagrant`_,
113+
`Docker`_, and `Windows Docker Machine`_. The virtual machine base image is
114+
acquired from `Vagrant Cloud`_, container images are acquired from the
115+
`Microsoft Container Registry`_. For provisioning additional software, the
116+
`Chocolatey`_ package manager is used. All of cmd, PowerShell and Bash are
117+
pre-installed on the container images.
118+
112119

113120
Operating system coverage
114121
-------------------------
@@ -132,6 +139,11 @@ Linux
132139
- SUSE SLES 15 and BCI:latest
133140
- Ubuntu LTS 20 and 22 (focal, jammy)
134141

142+
Windows
143+
.......
144+
- Windows Server Core LTSC 2016, 2019, and 2022
145+
- Windows Nano Server 1809 and LTSC 2022
146+
135147

136148
Prior art
137149
---------
@@ -212,7 +224,7 @@ Racker
212224
The ``racker`` program aims to resemble the semantics of Docker by providing a
213225
command line interface compatible with the ``docker`` command.
214226

215-
::
227+
Linux examples::
216228

217229
# Invoke the vanilla Docker `hello-world` image.
218230
# FIXME: Does not work yet.
@@ -244,6 +256,42 @@ command line interface compatible with the ``docker`` command.
244256
time echo "hello world" | racker run -it --rm fedora:37 cat /dev/stdin > hello
245257
cat hello
246258

259+
Windows examples::
260+
261+
# Windows OS images, mostly LTSC (Long-Term Servicing Channel).
262+
# Please note the download sizes.
263+
# Nanoserver: 250 MB, Servercore: 6 GB, Servercore with Java: 7 GB, Windows: 15 GB
264+
265+
# Launch an interactive command prompt (cmd, PowerShell or Bash).
266+
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 powershell
267+
268+
# Launch a single command.
269+
racker --verbose run --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 -- 'powershell -Command {echo "Hello, world."}'
270+
racker --verbose run --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 'sh -c "echo Hello, world."'
271+
272+
# Inquire system information.
273+
racker run --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 wmic os get caption
274+
racker run --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 'powershell -Command Get-ComputerInfo'
275+
276+
# Use stdin and stdout, with time keeping.
277+
time racker --verbose run --rm --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:1809-amd64 cmd /C echo "Hello, world." > hello
278+
cat hello
279+
280+
# Invoke a Java command prompt (JShell) with different Java versions.
281+
racker run -it --rm --platform=windows/amd64 openjdk:18-windowsservercore-1809 jshell
282+
racker run -it --rm --platform=windows/amd64 eclipse-temurin:18-jdk jshell
283+
System.out.println("OS: " + System.getProperty("os.name") + ", version " + System.getProperty("os.version"))
284+
System.out.println("Java: " + System.getProperty("java.vendor") + ", version " + System.getProperty("java.version"))
285+
/exit
286+
287+
# Windows Nano Server.
288+
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:1809-amd64 cmd
289+
racker --verbose run --rm --platform=windows/amd64 mcr.microsoft.com/windows/nanoserver:1809-amd64 cmd /C echo Hello, world.
290+
291+
# Full Windows.
292+
racker --verbose run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows:1809-amd64 cmd
293+
294+
247295

248296
Postroj
249297
=======

doc/cratedb.rst

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,52 @@
1-
#########################
2-
Using postroj for CrateDB
3-
#########################
1+
#######################################
2+
Using Racker and Postroj for CrateDB CI
3+
#######################################
44

55
.. note::
66

77
This is still a work in progress.
88

99

10+
*************
11+
Prerequisites
12+
*************
13+
14+
When creating the "Windows Docker Machine" virtual machine, the program will
15+
configure it to use 6 VPUs and 6144 MB system memory.
16+
17+
In order to adjust those values, use these environment variables before
18+
invoking the later commands::
19+
20+
export RACKER_VM_VCPUS=12
21+
export RACKER_VM_MEMORY=8192
22+
23+
If you want to adjust the values after the initial deployment, you will have to
24+
reset the "Windows Docker Machine" installation directory. For example, it is:
25+
26+
- On Linux: ``/root/.local/state/racker/windows-docker-machine``
27+
- On macOS: ``/Users/amo/Library/Application Support/racker/windows-docker-machine``
28+
29+
30+
31+
**********
32+
racker run
33+
**********
34+
35+
Purpose: Invoke programs in a Java/OpenJDK environment, within a
36+
virtualized/dockerized Windows installation.
37+
38+
Run the CrateDB test suite on OpenJDK 18 (Eclipse Temurin)::
39+
40+
time racker run --rm --platform=windows/amd64 eclipse-temurin:18-jdk \
41+
"sh -c 'mkdir /c/src; cd /c/src; git clone https://github.com/crate/crate --depth=1; cd crate; ./gradlew --no-daemon --parallel -PtestForks=2 :server:test -Dtests.crate.run-windows-incompatible=false --stacktrace'"
42+
43+
Invoke a Java command prompt (JShell) with OpenJDK 18::
44+
45+
racker run -it --rm --platform=windows/amd64 eclipse-temurin:18-jdk jshell
46+
System.out.println("OS: " + System.getProperty("os.name") + ", version " + System.getProperty("os.version"))
47+
System.out.println("Java: " + System.getProperty("java.vendor") + ", version " + System.getProperty("java.version"))
48+
49+
1050
****************
1151
postroj pkgprobe
1252
****************

doc/winrunner.rst

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#################
2-
postroj winrunner
3-
#################
1+
##############
2+
Windows runner
3+
##############
44

55
.. note::
66

@@ -11,25 +11,22 @@ postroj winrunner
1111
About
1212
*****
1313

14-
- https://github.com/PyTables/PyTables/pull/872#issuecomment-773535041
15-
14+
Launch an interactive command prompt (cmd, PowerShell or Bash) within a Windows
15+
environment or invoke programs non-interactively.
1616

17-
********
18-
Synopsis
19-
********
20-
::
17+
References
18+
==========
2119

22-
# Basic usage.
23-
postroj invoke --system=windows-1809 -- cmd /C echo hello
20+
- https://github.com/PyTables/PyTables/pull/872#issuecomment-773535041
2421

2522

2623
*****
2724
Setup
2825
*****
2926
::
3027

31-
# Install VirtualBox, Vagrant and Docker.
32-
brew install virtualbox docker vagrant
28+
# Install VirtualBox, Vagrant, and Docker.
29+
brew install virtualbox vagrant docker
3330

3431
# Install Windows VM with Docker environment.
3532
git clone https://github.com/StefanScherer/windows-docker-machine
@@ -47,6 +44,38 @@ Setup
4744
Usage
4845
*****
4946

47+
Basic usage::
48+
49+
racker run --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 \
50+
cmd /C echo "Hello, world."
51+
52+
Install software packages using `Chocolatey`_::
53+
54+
racker run -it --rm --platform=windows/amd64 mcr.microsoft.com/windows/servercore:ltsc2019-amd64 \
55+
powershell
56+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
57+
choco install --yes git
58+
Install-ChocolateyPath -PathToInstall "$($env:SystemDrive)\Program Files\Git\bin"
59+
60+
61+
*************
62+
Miscellaneous
63+
*************
64+
65+
Manipulating ``PATH``
66+
=====================
67+
68+
Display the content of the ``PATH`` environment variable::
69+
70+
echo %PATH%
71+
(Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path).Path
72+
73+
Set the content of the ``PATH`` environment variable::
74+
75+
setx PATH "$env:path;$($env:SystemDrive)\Program Files\Git\bin" -m
76+
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";$($env:SystemDrive)\Program Files\Git\bin", "Machine")
77+
78+
5079
Which shell spawns faster?
5180
==========================
5281
::
@@ -79,3 +108,5 @@ Terminate an environment::
79108
docker --context=2019-box ps
80109
docker --context=2019-box stop 5e2fe406ccbc
81110

111+
112+
.. _Chocolatey: https://chocolatey.org/

postroj/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import click
66

7-
from postroj import pkgprobe, runner, selftest, winrunner
7+
from postroj import pkgprobe, selftest
88
from postroj.api import pull_multiple_images, pull_single_image
99
from postroj.registry import list_images
1010
from postroj.util import boot
@@ -48,6 +48,5 @@ def cli_pull(ctx: click.Context, name: str, pull_all: bool = False):
4848

4949
cli.add_command(cmd=cli_list_images, name="list-images")
5050
cli.add_command(cmd=cli_pull, name="pull")
51-
cli.add_command(cmd=runner.invoke, name="invoke")
5251
cli.add_command(cmd=pkgprobe.main, name="pkgprobe")
5352
cli.add_command(cmd=selftest.selftest_main, name="selftest")

postroj/runner.py

Lines changed: 0 additions & 38 deletions
This file was deleted.

postroj/winrunner.Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Provision a Windows operating system image with additional software.
2+
# Automatically installs the open source version of the Chocolatey package manager.
3+
# By default, it installs `git`, `curl`, and `wget`.
4+
5+
ARG BASE_IMAGE
6+
7+
FROM ${BASE_IMAGE}
8+
9+
# Install the Chocolatey package manager.
10+
RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
11+
12+
# Install essential and convenience programs.
13+
# TODO: Verify that the right `curl` program has priority within the program search path.
14+
RUN choco install --yes git curl wget
15+
16+
# Make `bash` (from Git Bash, MINGW64) available on the program search path.
17+
RUN powershell ([Environment]::SetEnvironmentVariable('Path', $env:Path + ';' + $($env:SystemDrive) + '\Program Files\Git\bin', 'Machine'))
18+
19+
# Display the program search path.
20+
RUN powershell echo \"(Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name Path).Path\"

0 commit comments

Comments
 (0)