diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b4f14fb..987dbbd 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -79,3 +79,17 @@ jobs: shell: powershell run: | cd ./2.11.x/tests; ./run-images-2019.ps1 + + windows-2022-2_11: + runs-on: windows-2022 + steps: + - name: Checkout code + uses: actions/checkout@v1 + - name: Build images + shell: powershell + run: | + cd ./2.11.x/tests; ./build-images-2022.ps1 + - name: Test images + shell: powershell + run: | + cd ./2.11.x/tests; ./run-images-2022.ps1 diff --git a/2.11.x/nanoserver-ltsc2022/Dockerfile b/2.11.x/nanoserver-ltsc2022/Dockerfile new file mode 100644 index 0000000..4b4cd6e --- /dev/null +++ b/2.11.x/nanoserver-ltsc2022/Dockerfile @@ -0,0 +1,9 @@ +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 +ENV NATS_DOCKERIZED 1 + +COPY --from=nats:2.11.0-preview.2-windowsservercore-ltsc2022 C:\\nats-server.exe C:\\nats-server.exe +COPY nats-server.conf C:\\nats-server.conf + +EXPOSE 4222 8222 6222 +ENTRYPOINT ["C:\\nats-server.exe"] +CMD ["--config", "nats-server.conf"] diff --git a/2.11.x/nanoserver-ltsc2022/Dockerfile.preview b/2.11.x/nanoserver-ltsc2022/Dockerfile.preview new file mode 100644 index 0000000..526e93a --- /dev/null +++ b/2.11.x/nanoserver-ltsc2022/Dockerfile.preview @@ -0,0 +1,12 @@ +ARG BASE_IMAGE=nats:2.11.0-preview.2-windowsservercore-ltsc2022 +FROM $BASE_IMAGE AS base + +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 +ENV NATS_DOCKERIZED 1 + +COPY --from=base C:\\nats-server.exe C:\\nats-server.exe +COPY nats-server.conf C:\\nats-server.conf + +EXPOSE 4222 8222 6222 +ENTRYPOINT ["C:\\nats-server.exe"] +CMD ["--config", "nats-server.conf"] diff --git a/2.11.x/nanoserver-ltsc2022/nats-server.conf b/2.11.x/nanoserver-ltsc2022/nats-server.conf new file mode 100644 index 0000000..ba2faf9 --- /dev/null +++ b/2.11.x/nanoserver-ltsc2022/nats-server.conf @@ -0,0 +1,27 @@ +# Client port of 4222 on all interfaces +port: 4222 + +# HTTP monitoring port +monitor_port: 8222 + +# This is for clustering multiple servers together. +cluster { + # It is recommended to set a cluster name + name: "my_cluster" + + # Route connections to be received on any interface on port 6222 + port: 6222 + + # Routes are protected, so need to use them with --routes flag + # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 + authorization { + user: ruser + password: T0pS3cr3t + timeout: 2 + } + + # Routes are actively solicited and connected to from this server. + # This Docker image has none by default, but you can pass a + # flag to the nats-server docker image to create one to an existing server. + routes = [] +} diff --git a/2.11.x/tests/build-images-2022.ps1 b/2.11.x/tests/build-images-2022.ps1 new file mode 100644 index 0000000..0ca3e1d --- /dev/null +++ b/2.11.x/tests/build-images-2022.ps1 @@ -0,0 +1,28 @@ +# Show statements as they run. +Set-PSDebug -Trace 2 +# Exit on error. +$ErrorActionPreference = "Stop" + +$ver = 'NATS_SERVER 2.11.0-preview.2'.Split(' ')[1] + +Write-Output '-- host info ---' +Write-Output $PSVersionTable +Write-Output (Get-WMIObject win32_operatingsystem).name +Write-Output (Get-WMIObject win32_operatingsystem).OSArchitecture + +# The windowsservercore images must be built before the nanoserver images. +cd "../windowsservercore-ltsc2022" +Write-Host "building windowsservercore-ltsc2022" +docker build --tag "nats:${ver}-windowsservercore-ltsc2022" . +if ($LASTEXITCODE -ne 0) { + exit 1 +} + +cd "../nanoserver-ltsc2022" +Write-Host "building nanoserver-ltsc2022" +docker build --tag "nats:${ver}-nanoserver-ltsc2022" . +if ($LASTEXITCODE -ne 0) { + exit 1 +} + +docker images diff --git a/2.11.x/tests/run-images-2022.ps1 b/2.11.x/tests/run-images-2022.ps1 new file mode 100644 index 0000000..3b68783 --- /dev/null +++ b/2.11.x/tests/run-images-2022.ps1 @@ -0,0 +1,24 @@ +# Show statements as they run. +Set-PSDebug -Trace 2 +# Exit on error. +$ErrorActionPreference = "Stop" + +$ver = "NATS_SERVER 2.11.0-preview.2".Split(" ")[1] + +$images = @( + "nats:${ver}-windowsservercore-ltsc2022", + "nats:${ver}-nanoserver-ltsc2022" +) + +foreach ($img in $images) { + Write-Output "running ${img}" + $runId = & docker run --detach "${img}" + sleep 1 + + Write-Output "checking ${img}" + docker ps --filter "id=${runId}" --filter "status=running" --quiet + if ($LASTEXITCODE -ne 0) { + exit 1 + } + docker kill $runId +} diff --git a/2.11.x/windowsservercore-ltsc2022/Dockerfile b/2.11.x/windowsservercore-ltsc2022/Dockerfile new file mode 100644 index 0000000..63a43ed --- /dev/null +++ b/2.11.x/windowsservercore-ltsc2022/Dockerfile @@ -0,0 +1,38 @@ +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +# Enable exit on error. +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] + +ENV NATS_DOCKERIZED 1 +ENV NATS_SERVER 2.11.0-preview.2 +ENV NATS_SERVER_DOWNLOAD https://github.com/nats-io/nats-server/releases/download/v${NATS_SERVER}/nats-server-v${NATS_SERVER}-windows-amd64.zip +ENV NATS_SERVER_SHASUM 7828fc1bc3e84180fa16a325ea555f135525f631fb937275e70c949a43b7da9f + +RUN Set-PSDebug -Trace 2 + +RUN Write-Host ('downloading from {0} ...' -f $env:NATS_SERVER_DOWNLOAD); \ + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ + Invoke-WebRequest -Uri $env:NATS_SERVER_DOWNLOAD -OutFile nats.zip; \ + \ + Write-Host ('verifying sha256 ({0}) ...' -f $env:NATS_SERVER_SHASUM); \ + if ((Get-FileHash nats.zip -Algorithm sha256).Hash -ne $env:NATS_SERVER_SHASUM) { \ + Write-Host 'FAILED!'; \ + exit 1; \ + }; \ + Write-Host 'extracting nats.zip'; \ + Expand-Archive -Path 'nats.zip' -DestinationPath .; \ + \ + Write-Host 'copying binary'; \ + Copy-Item nats-server-v*/nats-server.exe -Destination C:\\nats-server.exe; \ + \ + Write-Host 'cleaning up'; \ + Remove-Item -Force nats.zip; \ + Remove-Item -Recurse -Force nats-server-v*; \ + \ + Write-Host 'complete.'; + +COPY nats-server.conf C:\\nats-server.conf + +EXPOSE 4222 8222 6222 +ENTRYPOINT ["C:\\nats-server.exe"] +CMD ["--config", "nats-server.conf"] diff --git a/2.11.x/windowsservercore-ltsc2022/nats-server.conf b/2.11.x/windowsservercore-ltsc2022/nats-server.conf new file mode 100644 index 0000000..ba2faf9 --- /dev/null +++ b/2.11.x/windowsservercore-ltsc2022/nats-server.conf @@ -0,0 +1,27 @@ +# Client port of 4222 on all interfaces +port: 4222 + +# HTTP monitoring port +monitor_port: 8222 + +# This is for clustering multiple servers together. +cluster { + # It is recommended to set a cluster name + name: "my_cluster" + + # Route connections to be received on any interface on port 6222 + port: 6222 + + # Routes are protected, so need to use them with --routes flag + # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 + authorization { + user: ruser + password: T0pS3cr3t + timeout: 2 + } + + # Routes are actively solicited and connected to from this server. + # This Docker image has none by default, but you can pass a + # flag to the nats-server docker image to create one to an existing server. + routes = [] +}