Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add windows ltsc2022 image builds #153

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions 2.11.x/nanoserver-ltsc2022/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
12 changes: 12 additions & 0 deletions 2.11.x/nanoserver-ltsc2022/Dockerfile.preview
Original file line number Diff line number Diff line change
@@ -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"]
27 changes: 27 additions & 0 deletions 2.11.x/nanoserver-ltsc2022/nats-server.conf
Original file line number Diff line number Diff line change
@@ -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 = []
}
28 changes: 28 additions & 0 deletions 2.11.x/tests/build-images-2022.ps1
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions 2.11.x/tests/run-images-2022.ps1
Original file line number Diff line number Diff line change
@@ -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
}
38 changes: 38 additions & 0 deletions 2.11.x/windowsservercore-ltsc2022/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
27 changes: 27 additions & 0 deletions 2.11.x/windowsservercore-ltsc2022/nats-server.conf
Original file line number Diff line number Diff line change
@@ -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 = []
}