├── .github └── workflows │ ├── images.yaml │ └── main.yaml ├── 2.10.x ├── alpine3.22 │ ├── Dockerfile │ ├── docker-entrypoint.sh │ └── nats-server.conf ├── nanoserver-ltsc2022 │ ├── Dockerfile │ ├── Dockerfile.preview │ └── nats-server.conf ├── nanoserver-ltsc2025 │ ├── Dockerfile │ ├── Dockerfile.preview │ └── nats-server.conf ├── scratch │ ├── Dockerfile │ ├── Dockerfile.preview │ └── nats-server.conf ├── tests │ ├── build-images-ltsc2022.ps1 │ ├── build-images-ltsc2025.ps1 │ ├── build-images.sh │ ├── run-images-ltsc2022.ps1 │ ├── run-images-ltsc2025.ps1 │ └── run-images.sh ├── windowsservercore-ltsc2022 │ ├── Dockerfile │ └── nats-server.conf └── windowsservercore-ltsc2025 │ ├── Dockerfile │ └── nats-server.conf ├── 2.11.x ├── alpine3.22 │ ├── Dockerfile │ ├── docker-entrypoint.sh │ └── nats-server.conf ├── nanoserver-ltsc2022 │ ├── Dockerfile │ ├── Dockerfile.preview │ └── nats-server.conf ├── nanoserver-ltsc2025 │ ├── Dockerfile │ ├── Dockerfile.preview │ └── nats-server.conf ├── scratch │ ├── Dockerfile │ ├── Dockerfile.preview │ └── nats-server.conf ├── tests │ ├── build-images-ltsc2022.ps1 │ ├── build-images-ltsc2025.ps1 │ ├── build-images.sh │ ├── run-images-ltsc2022.ps1 │ ├── run-images-ltsc2025.ps1 │ └── run-images.sh ├── windowsservercore-ltsc2022 │ ├── Dockerfile │ └── nats-server.conf └── windowsservercore-ltsc2025 │ ├── Dockerfile │ └── nats-server.conf ├── LICENSE ├── README.md └── update.py /.github/workflows/images.yaml: -------------------------------------------------------------------------------- 1 | name: Build Images 2 | 3 | on: 4 | push: 5 | tags: 6 | - "*" 7 | 8 | permissions: 9 | contents: read 10 | 11 | env: 12 | IMAGE_NAME: "synadia/nats-server" 13 | LINUX_ARCHS: "linux/arm64,linux/arm/v6,linux/arm/v7,linux/amd64,linux/386,linux/s390x,linux/ppc64le" 14 | 15 | jobs: 16 | linux-2_10: 17 | name: Build Linux (2.10.x) 18 | if: ${{ startsWith(github.ref_name, 'v2.10.') }} 19 | runs-on: ubuntu-latest 20 | 21 | steps: 22 | - name: Checkout repository 23 | uses: actions/checkout@v4 24 | 25 | - name: Log into Docker 26 | uses: docker/login-action@v3 27 | with: 28 | username: ${{ secrets.DOCKER_USERNAME }} 29 | password: ${{ secrets.DOCKER_TOKEN }} 30 | 31 | - name: Set up Docker Buildx 32 | uses: docker/setup-buildx-action@v3 33 | 34 | # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter 35 | - name: Tag Version 36 | id: ref 37 | shell: bash 38 | run: | 39 | TAG=${{ github.ref_name }} 40 | echo "TAG=${TAG#v}" >> "$GITHUB_OUTPUT" 41 | 42 | - name: Alpine 3.21 43 | uses: docker/build-push-action@v6 44 | with: 45 | context: ./2.10.x/alpine3.22/ 46 | platforms: ${{ env.LINUX_ARCHS }} 47 | push: true 48 | tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.22 49 | provenance: mode=max 50 | 51 | - name: Scratch 52 | uses: docker/build-push-action@v6 53 | with: 54 | context: ./2.10.x/scratch/ 55 | file: ./2.10.x/scratch/Dockerfile.preview 56 | platforms: ${{ env.LINUX_ARCHS }} 57 | push: true 58 | tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-scratch 59 | provenance: mode=max 60 | build-args: | 61 | BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.22 62 | 63 | windows-2_10: 64 | name: Test Windows Server LTSC ${{ matrix.ltsc }} (${{ matrix.version }}) 65 | if: ${{ startsWith(github.ref_name, 'v2.10.') }} 66 | runs-on: windows-${{ matrix.ltsc }} 67 | strategy: 68 | fail-fast: false 69 | matrix: 70 | version: 71 | - 2.10.x 72 | ltsc: 73 | - 2022 74 | # - 2025 75 | 76 | steps: 77 | - name: Checkout repository 78 | uses: actions/checkout@v4 79 | 80 | - name: Log into Docker 81 | uses: docker/login-action@v3 82 | with: 83 | username: ${{ secrets.DOCKER_USERNAME }} 84 | password: ${{ secrets.DOCKER_TOKEN }} 85 | 86 | # NOTE: bash is supported on Windows runners 87 | # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter 88 | - name: Tag Version 89 | id: ref 90 | shell: bash 91 | run: | 92 | TAG=${{ github.ref_name }} 93 | echo "TAG=${TAG#v}" >> "$GITHUB_OUTPUT" 94 | 95 | # Buildx is not supported on Windows yet. 96 | - name: windowsservercore-ltsc${{ matrix.ltsc }} 97 | shell: pwsh 98 | run: | 99 | docker build ` 100 | --tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-windowsservercore-ltsc${{ matrix.ltsc }}" ` 101 | ./${{ matrix.version }}/windowsservercore-ltsc${{ matrix.ltsc }} 102 | 103 | docker push "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-windowsservercore-ltsc${{ matrix.ltsc }}" 104 | 105 | - name: nanoserver-ltsc${{ matrix.ltsc }} 106 | shell: pwsh 107 | run: | 108 | docker build ` 109 | --file ./${{ matrix.version }}/nanoserver-ltsc${{ matrix.ltsc }}/Dockerfile.preview ` 110 | --build-arg "BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-windowsservercore-ltsc${{ matrix.ltsc }}" ` 111 | --tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-nanoserver-ltsc${{ matrix.ltsc }}" ` 112 | ./${{ matrix.version }}/nanoserver-ltsc${{ matrix.ltsc }} 113 | 114 | docker push "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-nanoserver-ltsc${{ matrix.ltsc }}" 115 | 116 | linux-2_11: 117 | name: Build Linux (2.11.x) 118 | if: ${{ startsWith(github.ref_name, 'v2.11.') }} 119 | runs-on: ubuntu-latest 120 | 121 | steps: 122 | - name: Checkout repository 123 | uses: actions/checkout@v4 124 | 125 | - name: Log into Docker 126 | uses: docker/login-action@v3 127 | with: 128 | username: ${{ secrets.DOCKER_USERNAME }} 129 | password: ${{ secrets.DOCKER_TOKEN }} 130 | 131 | - name: Set up Docker Buildx 132 | uses: docker/setup-buildx-action@v3 133 | 134 | - name: Tag Version 135 | id: ref 136 | shell: bash 137 | run: | 138 | TAG=${{ github.ref_name }} 139 | echo "TAG=${TAG#v}" >> "$GITHUB_OUTPUT" 140 | 141 | - name: Alpine 3.21 142 | uses: docker/build-push-action@v6 143 | with: 144 | context: ./2.11.x/alpine3.22/ 145 | platforms: ${{ env.LINUX_ARCHS }} 146 | push: true 147 | tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.22 148 | provenance: mode=max 149 | 150 | - name: Scratch 151 | uses: docker/build-push-action@v6 152 | with: 153 | context: ./2.11.x/scratch/ 154 | file: ./2.11.x/scratch/Dockerfile.preview 155 | platforms: ${{ env.LINUX_ARCHS }} 156 | push: true 157 | tags: ${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-scratch 158 | provenance: mode=max 159 | build-args: | 160 | BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-alpine3.22 161 | 162 | windows-2_11: 163 | name: Test Windows Server LTSC ${{ matrix.ltsc }} (${{ matrix.version }}) 164 | if: ${{ startsWith(github.ref_name, 'v2.11.') }} 165 | runs-on: windows-${{ matrix.ltsc }} 166 | strategy: 167 | fail-fast: false 168 | matrix: 169 | version: 170 | - 2.11.x 171 | ltsc: 172 | - 2022 173 | # - 2025 174 | 175 | steps: 176 | - name: Checkout repository 177 | uses: actions/checkout@v4 178 | 179 | - name: Log into Docker 180 | uses: docker/login-action@v3 181 | with: 182 | username: ${{ secrets.DOCKER_USERNAME }} 183 | password: ${{ secrets.DOCKER_TOKEN }} 184 | 185 | # NOTE: bash is supported on Windows runners 186 | # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter 187 | - name: Tag Version 188 | id: ref 189 | shell: bash 190 | run: | 191 | TAG=${{ github.ref_name }} 192 | echo "TAG=${TAG#v}" >> "$GITHUB_OUTPUT" 193 | 194 | # Buildx is not supported on Windows yet. 195 | - name: windowsservercore-ltsc${{ matrix.ltsc }} 196 | shell: pwsh 197 | run: | 198 | docker build ` 199 | --tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-windowsservercore-ltsc${{ matrix.ltsc }}" ` 200 | ./${{ matrix.version }}/windowsservercore-ltsc${{ matrix.ltsc }} 201 | 202 | docker push "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-windowsservercore-ltsc${{ matrix.ltsc }}" 203 | 204 | - name: nanoserver-ltsc${{ matrix.ltsc }} 205 | shell: pwsh 206 | run: | 207 | docker build ` 208 | --file ./${{ matrix.version }}/nanoserver-ltsc${{ matrix.ltsc }}/Dockerfile.preview ` 209 | --build-arg "BASE_IMAGE=${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-windowsservercore-ltsc${{ matrix.ltsc }}" ` 210 | --tag "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-nanoserver-ltsc${{ matrix.ltsc }}" ` 211 | ./${{ matrix.version }}/nanoserver-ltsc${{ matrix.ltsc }} 212 | 213 | docker push "${{ env.IMAGE_NAME }}:${{ steps.ref.outputs.TAG }}-nanoserver-ltsc${{ matrix.ltsc }}" 214 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: Docker build testing 2 | on: [push, pull_request] 3 | 4 | permissions: 5 | contents: read 6 | 7 | jobs: 8 | linux: 9 | name: Test Linux (${{ matrix.version }}) 10 | runs-on: ubuntu-latest 11 | strategy: 12 | fail-fast: false 13 | matrix: 14 | version: 15 | - 2.10.x 16 | - 2.11.x 17 | steps: 18 | - name: Checkout code 19 | uses: actions/checkout@v1 20 | - name: Build ${{ matrix.version }} images 21 | run: | 22 | cd ./${{ matrix.version }}/tests && ./build-images.sh 23 | - name: Test ${{ matrix.version }} images 24 | run: | 25 | cd ./${{ matrix.version }}/tests && ./run-images.sh 26 | 27 | windows: 28 | name: Test Windows Server LTSC ${{ matrix.ltsc }} (${{ matrix.version }}) 29 | runs-on: windows-${{ matrix.ltsc }} 30 | strategy: 31 | fail-fast: false 32 | matrix: 33 | version: 34 | - 2.10.x 35 | - 2.11.x 36 | ltsc: 37 | - 2022 38 | # - 2025 39 | steps: 40 | - name: Checkout code 41 | uses: actions/checkout@v1 42 | - name: Build images 43 | shell: powershell 44 | run: | 45 | cd ./${{ matrix.version }}/tests; ./build-images-ltsc${{ matrix.ltsc }}.ps1 46 | - name: Test images 47 | shell: powershell 48 | run: | 49 | cd ./${{ matrix.version }}/tests; ./run-images-ltsc${{ matrix.ltsc }}.ps1 50 | -------------------------------------------------------------------------------- /2.10.x/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.22 2 | 3 | ENV NATS_SERVER 2.10.29 4 | 5 | RUN set -eux; \ 6 | apkArch="$(apk --print-arch)"; \ 7 | case "$apkArch" in \ 8 | aarch64) natsArch='arm64'; sha256='da4b27942ecfb4c5f0c54553d2e7f470ddda9d7581cfe8131b351a0e223ed401' ;; \ 9 | armhf) natsArch='arm6'; sha256='7b70fd23bfbd9efa7ca5edb5aa18fe33b07ff993ac86db06372af297bfaf6fab' ;; \ 10 | armv7) natsArch='arm7'; sha256='a59e7336a32ef78b0ca8bc3e6707a5770461d3f45c4c2f96cfef263f26eaefd5' ;; \ 11 | x86_64) natsArch='amd64'; sha256='e314da74a83a1d3876db8814c27eb990fe729640fd6452025b441bcede8390da' ;; \ 12 | x86) natsArch='386'; sha256='abc385394c19784558f7aa2f9770fe2daceb22cf95e3fa398c832590479396b0' ;; \ 13 | s390x) natsArch='s390x'; sha256='ee821b1eae8bb98a0d4603510a41613dd15afef244261a79da33515699d1aece' ;; \ 14 | ppc64le) natsArch='ppc64le'; sha256='31b0063d261e5d8c59396f8a3f9298ad80b36fd4bc370ce59e5d160f55a0fe46' ;; \ 15 | *) echo >&2 "error: $apkArch is not supported!"; exit 1 ;; \ 16 | esac; \ 17 | \ 18 | wget -O nats-server.tar.gz "https://github.com/nats-io/nats-server/releases/download/v${NATS_SERVER}/nats-server-v${NATS_SERVER}-linux-${natsArch}.tar.gz"; \ 19 | echo "${sha256} *nats-server.tar.gz" | sha256sum -c -; \ 20 | \ 21 | apk add --no-cache ca-certificates tzdata; \ 22 | \ 23 | tar -xf nats-server.tar.gz; \ 24 | rm nats-server.tar.gz; \ 25 | mv "nats-server-v${NATS_SERVER}-linux-${natsArch}/nats-server" /usr/local/bin; \ 26 | rm -rf "nats-server-v${NATS_SERVER}-linux-${natsArch}"; 27 | 28 | COPY nats-server.conf /etc/nats/nats-server.conf 29 | COPY docker-entrypoint.sh /usr/local/bin 30 | 31 | EXPOSE 4222 8222 6222 32 | ENTRYPOINT ["docker-entrypoint.sh"] 33 | CMD ["nats-server", "--config", "/etc/nats/nats-server.conf"] 34 | -------------------------------------------------------------------------------- /2.10.x/alpine3.22/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # this if will check if the first argument is a flag 5 | # but only works if all arguments require a hyphenated flag 6 | # -v; -SL; -f arg; etc will work, but not arg1 arg2 7 | if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then 8 | set -- nats-server "$@" 9 | fi 10 | 11 | # else default to run whatever the user wanted like "bash" or "sh" 12 | exec "$@" 13 | 14 | -------------------------------------------------------------------------------- /2.10.x/alpine3.22/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.10.x/nanoserver-ltsc2022/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 2 | ENV NATS_DOCKERIZED 1 3 | 4 | COPY --from=nats:2.10.29-windowsservercore-ltsc2022 C:\\nats-server.exe C:\\nats-server.exe 5 | COPY nats-server.conf C:\\nats-server.conf 6 | 7 | EXPOSE 4222 8222 6222 8 | ENTRYPOINT ["C:\\nats-server.exe"] 9 | CMD ["--config", "nats-server.conf"] 10 | -------------------------------------------------------------------------------- /2.10.x/nanoserver-ltsc2022/Dockerfile.preview: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE=nats:2.10.29-windowsservercore-ltsc2022 2 | FROM $BASE_IMAGE AS base 3 | 4 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 5 | ENV NATS_DOCKERIZED 1 6 | 7 | COPY --from=base C:\\nats-server.exe C:\\nats-server.exe 8 | COPY nats-server.conf C:\\nats-server.conf 9 | 10 | EXPOSE 4222 8222 6222 11 | ENTRYPOINT ["C:\\nats-server.exe"] 12 | CMD ["--config", "nats-server.conf"] 13 | -------------------------------------------------------------------------------- /2.10.x/nanoserver-ltsc2022/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.10.x/nanoserver-ltsc2025/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 2 | ENV NATS_DOCKERIZED 1 3 | 4 | COPY --from=nats:2.10.29-windowsservercore-ltsc2025 C:\\nats-server.exe C:\\nats-server.exe 5 | COPY nats-server.conf C:\\nats-server.conf 6 | 7 | EXPOSE 4222 8222 6222 8 | ENTRYPOINT ["C:\\nats-server.exe"] 9 | CMD ["--config", "nats-server.conf"] 10 | -------------------------------------------------------------------------------- /2.10.x/nanoserver-ltsc2025/Dockerfile.preview: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE=nats:2.10.29-windowsservercore-ltsc2025 2 | FROM $BASE_IMAGE AS base 3 | 4 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 5 | ENV NATS_DOCKERIZED 1 6 | 7 | COPY --from=base C:\\nats-server.exe C:\\nats-server.exe 8 | COPY nats-server.conf C:\\nats-server.conf 9 | 10 | EXPOSE 4222 8222 6222 11 | ENTRYPOINT ["C:\\nats-server.exe"] 12 | CMD ["--config", "nats-server.conf"] 13 | -------------------------------------------------------------------------------- /2.10.x/nanoserver-ltsc2025/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.10.x/scratch/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | ENV PATH="$PATH:/" 3 | 4 | COPY --from=nats:2.10.29-alpine3.22 /usr/local/bin/nats-server /nats-server 5 | COPY nats-server.conf /nats-server.conf 6 | 7 | EXPOSE 4222 8222 6222 8 | ENTRYPOINT ["/nats-server"] 9 | CMD ["--config", "nats-server.conf"] 10 | -------------------------------------------------------------------------------- /2.10.x/scratch/Dockerfile.preview: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE=nats:2.10.29-alpine3.22 2 | FROM $BASE_IMAGE AS base 3 | 4 | FROM scratch 5 | ENV PATH="$PATH:/" 6 | 7 | COPY --from=base /usr/local/bin/nats-server /nats-server 8 | COPY nats-server.conf /nats-server.conf 9 | 10 | EXPOSE 4222 8222 6222 11 | ENTRYPOINT ["/nats-server"] 12 | CMD ["--config", "nats-server.conf"] 13 | -------------------------------------------------------------------------------- /2.10.x/scratch/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.10.x/tests/build-images-ltsc2022.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = 'NATS_SERVER 2.10.29'.Split(' ')[1] 7 | 8 | Write-Output '-- host info ---' 9 | Write-Output $PSVersionTable 10 | Write-Output (Get-WMIObject win32_operatingsystem).name 11 | Write-Output (Get-WMIObject win32_operatingsystem).OSArchitecture 12 | 13 | # The windowsservercore images must be built before the nanoserver images. 14 | cd "../windowsservercore-ltsc2022" 15 | Write-Host "building windowsservercore-ltsc2022" 16 | docker build --tag "nats:${ver}-windowsservercore-ltsc2022" . 17 | if ($LASTEXITCODE -ne 0) { 18 | exit 1 19 | } 20 | 21 | cd "../nanoserver-ltsc2022" 22 | Write-Host "building nanoserver-ltsc2022" 23 | docker build --tag "nats:${ver}-nanoserver-ltsc2022" . 24 | if ($LASTEXITCODE -ne 0) { 25 | exit 1 26 | } 27 | 28 | docker images 29 | -------------------------------------------------------------------------------- /2.10.x/tests/build-images-ltsc2025.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = 'NATS_SERVER 2.10.29'.Split(' ')[1] 7 | 8 | Write-Output '-- host info ---' 9 | Write-Output $PSVersionTable 10 | Write-Output (Get-WMIObject win32_operatingsystem).name 11 | Write-Output (Get-WMIObject win32_operatingsystem).OSArchitecture 12 | 13 | # The windowsservercore images must be built before the nanoserver images. 14 | cd "../windowsservercore-ltsc2025" 15 | Write-Host "building windowsservercore-ltsc2025" 16 | docker build --tag "nats:${ver}-windowsservercore-ltsc2025" . 17 | if ($LASTEXITCODE -ne 0) { 18 | exit 1 19 | } 20 | 21 | cd "../nanoserver-ltsc2025" 22 | Write-Host "building nanoserver-ltsc2025" 23 | docker build --tag "nats:${ver}-nanoserver-ltsc2025" . 24 | if ($LASTEXITCODE -ne 0) { 25 | exit 1 26 | } 27 | 28 | docker images 29 | -------------------------------------------------------------------------------- /2.10.x/tests/build-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | ver=(NATS_SERVER 2.10.29) 5 | 6 | ( 7 | cd "../alpine3.22" 8 | docker build --tag nats:${ver[1]}-alpine3.22 . 9 | ) 10 | 11 | ( 12 | cd "../scratch" 13 | docker build --tag nats:${ver[1]}-scratch . 14 | ) 15 | -------------------------------------------------------------------------------- /2.10.x/tests/run-images-ltsc2022.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = "NATS_SERVER 2.10.29".Split(" ")[1] 7 | 8 | $images = @( 9 | "nats:${ver}-windowsservercore-ltsc2022", 10 | "nats:${ver}-nanoserver-ltsc2022" 11 | ) 12 | 13 | foreach ($img in $images) { 14 | Write-Output "running ${img}" 15 | $runId = & docker run --detach "${img}" 16 | sleep 1 17 | 18 | Write-Output "checking ${img}" 19 | docker ps --filter "id=${runId}" --filter "status=running" --quiet 20 | if ($LASTEXITCODE -ne 0) { 21 | exit 1 22 | } 23 | docker kill $runId 24 | } 25 | -------------------------------------------------------------------------------- /2.10.x/tests/run-images-ltsc2025.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = "NATS_SERVER 2.10.29".Split(" ")[1] 7 | 8 | $images = @( 9 | "nats:${ver}-windowsservercore-ltsc2025", 10 | "nats:${ver}-nanoserver-ltsc2025" 11 | ) 12 | 13 | foreach ($img in $images) { 14 | Write-Output "running ${img}" 15 | $runId = & docker run --detach "${img}" 16 | sleep 1 17 | 18 | Write-Output "checking ${img}" 19 | docker logs "$runId" 20 | docker ps --filter "id=${runId}" --filter "status=running" --quiet 21 | if ($LASTEXITCODE -ne 0) { 22 | exit 1 23 | } 24 | docker kill $runId 25 | } 26 | -------------------------------------------------------------------------------- /2.10.x/tests/run-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | ver=(NATS_SERVER 2.10.29) 5 | 6 | images=( 7 | "nats:${ver[1]}-alpine3.22" 8 | "nats:${ver[1]}-scratch" 9 | ) 10 | 11 | for img in "${images[@]}"; do 12 | run_id=$(docker run --detach "${img}") 13 | sleep 1 14 | test -n "$(docker ps --filter "id=${run_id}" --filter "status=running" --quiet)" 15 | docker kill "$run_id" 16 | done 17 | -------------------------------------------------------------------------------- /2.10.x/windowsservercore-ltsc2022/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/servercore:ltsc2022 2 | 3 | # Enable exit on error. 4 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] 5 | 6 | ENV NATS_DOCKERIZED 1 7 | ENV NATS_SERVER 2.10.29 8 | ENV NATS_SERVER_DOWNLOAD https://github.com/nats-io/nats-server/releases/download/v${NATS_SERVER}/nats-server-v${NATS_SERVER}-windows-amd64.zip 9 | ENV NATS_SERVER_SHASUM 98657bf4d5a9ce44168c019ba6894cda8e22e6adc8798edc05c168db7262de29 10 | 11 | RUN Set-PSDebug -Trace 2 12 | 13 | RUN Write-Host ('downloading from {0} ...' -f $env:NATS_SERVER_DOWNLOAD); \ 14 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 15 | Invoke-WebRequest -Uri $env:NATS_SERVER_DOWNLOAD -OutFile nats.zip; \ 16 | \ 17 | Write-Host ('verifying sha256 ({0}) ...' -f $env:NATS_SERVER_SHASUM); \ 18 | if ((Get-FileHash nats.zip -Algorithm sha256).Hash -ne $env:NATS_SERVER_SHASUM) { \ 19 | Write-Host 'FAILED!'; \ 20 | exit 1; \ 21 | }; \ 22 | Write-Host 'extracting nats.zip'; \ 23 | Expand-Archive -Path 'nats.zip' -DestinationPath .; \ 24 | \ 25 | Write-Host 'copying binary'; \ 26 | Copy-Item nats-server-v*/nats-server.exe -Destination C:\\nats-server.exe; \ 27 | \ 28 | Write-Host 'cleaning up'; \ 29 | Remove-Item -Force nats.zip; \ 30 | Remove-Item -Recurse -Force nats-server-v*; \ 31 | \ 32 | Write-Host 'complete.'; 33 | 34 | COPY nats-server.conf C:\\nats-server.conf 35 | 36 | EXPOSE 4222 8222 6222 37 | ENTRYPOINT ["C:\\nats-server.exe"] 38 | CMD ["--config", "nats-server.conf"] 39 | -------------------------------------------------------------------------------- /2.10.x/windowsservercore-ltsc2022/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.10.x/windowsservercore-ltsc2025/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/servercore:ltsc2025 2 | 3 | # Enable exit on error. 4 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] 5 | 6 | ENV NATS_DOCKERIZED 1 7 | ENV NATS_SERVER 2.10.29 8 | ENV NATS_SERVER_DOWNLOAD https://github.com/nats-io/nats-server/releases/download/v${NATS_SERVER}/nats-server-v${NATS_SERVER}-windows-amd64.zip 9 | ENV NATS_SERVER_SHASUM 98657bf4d5a9ce44168c019ba6894cda8e22e6adc8798edc05c168db7262de29 10 | 11 | RUN Set-PSDebug -Trace 2 12 | 13 | RUN Write-Host ('downloading from {0} ...' -f $env:NATS_SERVER_DOWNLOAD); \ 14 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 15 | Invoke-WebRequest -Uri $env:NATS_SERVER_DOWNLOAD -OutFile nats.zip; \ 16 | \ 17 | Write-Host ('verifying sha256 ({0}) ...' -f $env:NATS_SERVER_SHASUM); \ 18 | if ((Get-FileHash nats.zip -Algorithm sha256).Hash -ne $env:NATS_SERVER_SHASUM) { \ 19 | Write-Host 'FAILED!'; \ 20 | exit 1; \ 21 | }; \ 22 | Write-Host 'extracting nats.zip'; \ 23 | Expand-Archive -Path 'nats.zip' -DestinationPath .; \ 24 | \ 25 | Write-Host 'copying binary'; \ 26 | Copy-Item nats-server-v*/nats-server.exe -Destination C:\\nats-server.exe; \ 27 | \ 28 | Write-Host 'cleaning up'; \ 29 | Remove-Item -Force nats.zip; \ 30 | Remove-Item -Recurse -Force nats-server-v*; \ 31 | \ 32 | Write-Host 'complete.'; 33 | 34 | COPY nats-server.conf C:\\nats-server.conf 35 | 36 | EXPOSE 4222 8222 6222 37 | ENTRYPOINT ["C:\\nats-server.exe"] 38 | CMD ["--config", "nats-server.conf"] 39 | -------------------------------------------------------------------------------- /2.10.x/windowsservercore-ltsc2025/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.11.x/alpine3.22/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.22 2 | 3 | ENV NATS_SERVER 2.11.4 4 | 5 | RUN set -eux; \ 6 | apkArch="$(apk --print-arch)"; \ 7 | case "$apkArch" in \ 8 | aarch64) natsArch='arm64'; sha256='66b1ec828d78c3d24e207ad77239b2208d939c6bebd88fe0656be5eae325442c' ;; \ 9 | armhf) natsArch='arm6'; sha256='89a2a3525e9c1882e69a3b8c7413887b35bce6badc7ed52434237e6f4201d6ca' ;; \ 10 | armv7) natsArch='arm7'; sha256='244b122197847bce9ac8734d85a4e0d340e9eb6683903b74adf5d1e54e840b11' ;; \ 11 | x86_64) natsArch='amd64'; sha256='84192cee46c62760d9c259a97f373b73bccadc41be779c26ef676542ae15daf6' ;; \ 12 | x86) natsArch='386'; sha256='3f6bbd7ee8537e364681d60854f7c443b1395942cbf50cafa23b28d0e1e9b697' ;; \ 13 | s390x) natsArch='s390x'; sha256='f04399991c43feed206d8ec77b748d3d4fdba2503f5153743f6f5f1937d1b1fc' ;; \ 14 | ppc64le) natsArch='ppc64le'; sha256='8867a9368f2bdc12bf2ad9fbb7bb63c4c5ba32434a17b57175b443805b2c5900' ;; \ 15 | *) echo >&2 "error: $apkArch is not supported!"; exit 1 ;; \ 16 | esac; \ 17 | \ 18 | wget -O nats-server.tar.gz "https://github.com/nats-io/nats-server/releases/download/v${NATS_SERVER}/nats-server-v${NATS_SERVER}-linux-${natsArch}.tar.gz"; \ 19 | echo "${sha256} *nats-server.tar.gz" | sha256sum -c -; \ 20 | \ 21 | apk add --no-cache ca-certificates tzdata; \ 22 | \ 23 | tar -xf nats-server.tar.gz; \ 24 | rm nats-server.tar.gz; \ 25 | mv "nats-server-v${NATS_SERVER}-linux-${natsArch}/nats-server" /usr/local/bin; \ 26 | rm -rf "nats-server-v${NATS_SERVER}-linux-${natsArch}"; 27 | 28 | COPY nats-server.conf /etc/nats/nats-server.conf 29 | COPY docker-entrypoint.sh /usr/local/bin 30 | 31 | EXPOSE 4222 8222 6222 32 | ENTRYPOINT ["docker-entrypoint.sh"] 33 | CMD ["nats-server", "--config", "/etc/nats/nats-server.conf"] 34 | -------------------------------------------------------------------------------- /2.11.x/alpine3.22/docker-entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # this if will check if the first argument is a flag 5 | # but only works if all arguments require a hyphenated flag 6 | # -v; -SL; -f arg; etc will work, but not arg1 arg2 7 | if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then 8 | set -- nats-server "$@" 9 | fi 10 | 11 | # else default to run whatever the user wanted like "bash" or "sh" 12 | exec "$@" 13 | 14 | -------------------------------------------------------------------------------- /2.11.x/alpine3.22/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.11.x/nanoserver-ltsc2022/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 2 | ENV NATS_DOCKERIZED 1 3 | 4 | COPY --from=nats:2.11.4-windowsservercore-ltsc2022 C:\\nats-server.exe C:\\nats-server.exe 5 | COPY nats-server.conf C:\\nats-server.conf 6 | 7 | EXPOSE 4222 8222 6222 8 | ENTRYPOINT ["C:\\nats-server.exe"] 9 | CMD ["--config", "nats-server.conf"] 10 | -------------------------------------------------------------------------------- /2.11.x/nanoserver-ltsc2022/Dockerfile.preview: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE=nats:2.11.4-windowsservercore-ltsc2022 2 | FROM $BASE_IMAGE AS base 3 | 4 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 5 | ENV NATS_DOCKERIZED 1 6 | 7 | COPY --from=base C:\\nats-server.exe C:\\nats-server.exe 8 | COPY nats-server.conf C:\\nats-server.conf 9 | 10 | EXPOSE 4222 8222 6222 11 | ENTRYPOINT ["C:\\nats-server.exe"] 12 | CMD ["--config", "nats-server.conf"] 13 | -------------------------------------------------------------------------------- /2.11.x/nanoserver-ltsc2022/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.11.x/nanoserver-ltsc2025/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 2 | ENV NATS_DOCKERIZED 1 3 | 4 | COPY --from=nats:2.11.4-windowsservercore-ltsc2025 C:\\nats-server.exe C:\\nats-server.exe 5 | COPY nats-server.conf C:\\nats-server.conf 6 | 7 | EXPOSE 4222 8222 6222 8 | ENTRYPOINT ["C:\\nats-server.exe"] 9 | CMD ["--config", "nats-server.conf"] 10 | -------------------------------------------------------------------------------- /2.11.x/nanoserver-ltsc2025/Dockerfile.preview: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE=nats:2.11.4-windowsservercore-ltsc2025 2 | FROM $BASE_IMAGE AS base 3 | 4 | FROM mcr.microsoft.com/windows/nanoserver:ltsc2025 5 | ENV NATS_DOCKERIZED 1 6 | 7 | COPY --from=base C:\\nats-server.exe C:\\nats-server.exe 8 | COPY nats-server.conf C:\\nats-server.conf 9 | 10 | EXPOSE 4222 8222 6222 11 | ENTRYPOINT ["C:\\nats-server.exe"] 12 | CMD ["--config", "nats-server.conf"] 13 | -------------------------------------------------------------------------------- /2.11.x/nanoserver-ltsc2025/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.11.x/scratch/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | ENV PATH="$PATH:/" 3 | 4 | COPY --from=nats:2.11.4-alpine3.22 /usr/local/bin/nats-server /nats-server 5 | COPY nats-server.conf /nats-server.conf 6 | 7 | EXPOSE 4222 8222 6222 8 | ENTRYPOINT ["/nats-server"] 9 | CMD ["--config", "nats-server.conf"] 10 | -------------------------------------------------------------------------------- /2.11.x/scratch/Dockerfile.preview: -------------------------------------------------------------------------------- 1 | ARG BASE_IMAGE=nats:2.11.4-alpine3.22 2 | FROM $BASE_IMAGE AS base 3 | 4 | FROM scratch 5 | ENV PATH="$PATH:/" 6 | 7 | COPY --from=base /usr/local/bin/nats-server /nats-server 8 | COPY nats-server.conf /nats-server.conf 9 | 10 | EXPOSE 4222 8222 6222 11 | ENTRYPOINT ["/nats-server"] 12 | CMD ["--config", "nats-server.conf"] 13 | -------------------------------------------------------------------------------- /2.11.x/scratch/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.11.x/tests/build-images-ltsc2022.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = 'NATS_SERVER 2.11.4'.Split(' ')[1] 7 | 8 | Write-Output '-- host info ---' 9 | Write-Output $PSVersionTable 10 | Write-Output (Get-WMIObject win32_operatingsystem).name 11 | Write-Output (Get-WMIObject win32_operatingsystem).OSArchitecture 12 | 13 | # The windowsservercore images must be built before the nanoserver images. 14 | cd "../windowsservercore-ltsc2022" 15 | Write-Host "building windowsservercore-ltsc2022" 16 | docker build --tag "nats:${ver}-windowsservercore-ltsc2022" . 17 | if ($LASTEXITCODE -ne 0) { 18 | exit 1 19 | } 20 | 21 | cd "../nanoserver-ltsc2022" 22 | Write-Host "building nanoserver-ltsc2022" 23 | docker build --tag "nats:${ver}-nanoserver-ltsc2022" . 24 | if ($LASTEXITCODE -ne 0) { 25 | exit 1 26 | } 27 | 28 | docker images 29 | -------------------------------------------------------------------------------- /2.11.x/tests/build-images-ltsc2025.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = 'NATS_SERVER 2.11.4'.Split(' ')[1] 7 | 8 | Write-Output '-- host info ---' 9 | Write-Output $PSVersionTable 10 | Write-Output (Get-WMIObject win32_operatingsystem).name 11 | Write-Output (Get-WMIObject win32_operatingsystem).OSArchitecture 12 | 13 | # The windowsservercore images must be built before the nanoserver images. 14 | cd "../windowsservercore-ltsc2025" 15 | Write-Host "building windowsservercore-ltsc2025" 16 | docker build --tag "nats:${ver}-windowsservercore-ltsc2025" . 17 | if ($LASTEXITCODE -ne 0) { 18 | exit 1 19 | } 20 | 21 | cd "../nanoserver-ltsc2025" 22 | Write-Host "building nanoserver-ltsc2025" 23 | docker build --tag "nats:${ver}-nanoserver-ltsc2025" . 24 | if ($LASTEXITCODE -ne 0) { 25 | exit 1 26 | } 27 | 28 | docker images 29 | -------------------------------------------------------------------------------- /2.11.x/tests/build-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | ver=(NATS_SERVER 2.11.4) 5 | 6 | ( 7 | cd "../alpine3.22" 8 | docker build --tag nats:${ver[1]}-alpine3.22 . 9 | ) 10 | 11 | ( 12 | cd "../scratch" 13 | docker build --tag nats:${ver[1]}-scratch . 14 | ) 15 | -------------------------------------------------------------------------------- /2.11.x/tests/run-images-ltsc2022.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = "NATS_SERVER 2.11.4".Split(" ")[1] 7 | 8 | $images = @( 9 | "nats:${ver}-windowsservercore-ltsc2022", 10 | "nats:${ver}-nanoserver-ltsc2022" 11 | ) 12 | 13 | foreach ($img in $images) { 14 | Write-Output "running ${img}" 15 | $runId = & docker run --detach "${img}" 16 | sleep 1 17 | 18 | Write-Output "checking ${img}" 19 | docker ps --filter "id=${runId}" --filter "status=running" --quiet 20 | if ($LASTEXITCODE -ne 0) { 21 | exit 1 22 | } 23 | docker kill $runId 24 | } 25 | -------------------------------------------------------------------------------- /2.11.x/tests/run-images-ltsc2025.ps1: -------------------------------------------------------------------------------- 1 | # Show statements as they run. 2 | Set-PSDebug -Trace 2 3 | # Exit on error. 4 | $ErrorActionPreference = "Stop" 5 | 6 | $ver = "NATS_SERVER 2.11.4".Split(" ")[1] 7 | 8 | $images = @( 9 | "nats:${ver}-windowsservercore-ltsc2025", 10 | "nats:${ver}-nanoserver-ltsc2025" 11 | ) 12 | 13 | foreach ($img in $images) { 14 | Write-Output "running ${img}" 15 | $runId = & docker run --detach "${img}" 16 | sleep 1 17 | 18 | Write-Output "checking ${img}" 19 | docker logs "$runId" 20 | docker ps --filter "id=${runId}" --filter "status=running" --quiet 21 | if ($LASTEXITCODE -ne 0) { 22 | exit 1 23 | } 24 | docker kill $runId 25 | } 26 | -------------------------------------------------------------------------------- /2.11.x/tests/run-images.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -ex 3 | 4 | ver=(NATS_SERVER 2.11.4) 5 | 6 | images=( 7 | "nats:${ver[1]}-alpine3.22" 8 | "nats:${ver[1]}-scratch" 9 | ) 10 | 11 | for img in "${images[@]}"; do 12 | run_id=$(docker run --detach "${img}") 13 | sleep 1 14 | test -n "$(docker ps --filter "id=${run_id}" --filter "status=running" --quiet)" 15 | docker kill "$run_id" 16 | done 17 | -------------------------------------------------------------------------------- /2.11.x/windowsservercore-ltsc2022/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/servercore:ltsc2022 2 | 3 | # Enable exit on error. 4 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] 5 | 6 | ENV NATS_DOCKERIZED 1 7 | ENV NATS_SERVER 2.11.4 8 | ENV NATS_SERVER_DOWNLOAD https://github.com/nats-io/nats-server/releases/download/v${NATS_SERVER}/nats-server-v${NATS_SERVER}-windows-amd64.zip 9 | ENV NATS_SERVER_SHASUM c78771905c52a8590f6c20cb101bb38ab65bd3046bd6ab8edf4e38efd41dce6f 10 | 11 | RUN Set-PSDebug -Trace 2 12 | 13 | RUN Write-Host ('downloading from {0} ...' -f $env:NATS_SERVER_DOWNLOAD); \ 14 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 15 | Invoke-WebRequest -Uri $env:NATS_SERVER_DOWNLOAD -OutFile nats.zip; \ 16 | \ 17 | Write-Host ('verifying sha256 ({0}) ...' -f $env:NATS_SERVER_SHASUM); \ 18 | if ((Get-FileHash nats.zip -Algorithm sha256).Hash -ne $env:NATS_SERVER_SHASUM) { \ 19 | Write-Host 'FAILED!'; \ 20 | exit 1; \ 21 | }; \ 22 | Write-Host 'extracting nats.zip'; \ 23 | Expand-Archive -Path 'nats.zip' -DestinationPath .; \ 24 | \ 25 | Write-Host 'copying binary'; \ 26 | Copy-Item nats-server-v*/nats-server.exe -Destination C:\\nats-server.exe; \ 27 | \ 28 | Write-Host 'cleaning up'; \ 29 | Remove-Item -Force nats.zip; \ 30 | Remove-Item -Recurse -Force nats-server-v*; \ 31 | \ 32 | Write-Host 'complete.'; 33 | 34 | COPY nats-server.conf C:\\nats-server.conf 35 | 36 | EXPOSE 4222 8222 6222 37 | ENTRYPOINT ["C:\\nats-server.exe"] 38 | CMD ["--config", "nats-server.conf"] 39 | -------------------------------------------------------------------------------- /2.11.x/windowsservercore-ltsc2022/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /2.11.x/windowsservercore-ltsc2025/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/windows/servercore:ltsc2025 2 | 3 | # Enable exit on error. 4 | SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] 5 | 6 | ENV NATS_DOCKERIZED 1 7 | ENV NATS_SERVER 2.11.4 8 | ENV NATS_SERVER_DOWNLOAD https://github.com/nats-io/nats-server/releases/download/v${NATS_SERVER}/nats-server-v${NATS_SERVER}-windows-amd64.zip 9 | ENV NATS_SERVER_SHASUM c78771905c52a8590f6c20cb101bb38ab65bd3046bd6ab8edf4e38efd41dce6f 10 | 11 | RUN Set-PSDebug -Trace 2 12 | 13 | RUN Write-Host ('downloading from {0} ...' -f $env:NATS_SERVER_DOWNLOAD); \ 14 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \ 15 | Invoke-WebRequest -Uri $env:NATS_SERVER_DOWNLOAD -OutFile nats.zip; \ 16 | \ 17 | Write-Host ('verifying sha256 ({0}) ...' -f $env:NATS_SERVER_SHASUM); \ 18 | if ((Get-FileHash nats.zip -Algorithm sha256).Hash -ne $env:NATS_SERVER_SHASUM) { \ 19 | Write-Host 'FAILED!'; \ 20 | exit 1; \ 21 | }; \ 22 | Write-Host 'extracting nats.zip'; \ 23 | Expand-Archive -Path 'nats.zip' -DestinationPath .; \ 24 | \ 25 | Write-Host 'copying binary'; \ 26 | Copy-Item nats-server-v*/nats-server.exe -Destination C:\\nats-server.exe; \ 27 | \ 28 | Write-Host 'cleaning up'; \ 29 | Remove-Item -Force nats.zip; \ 30 | Remove-Item -Recurse -Force nats-server-v*; \ 31 | \ 32 | Write-Host 'complete.'; 33 | 34 | COPY nats-server.conf C:\\nats-server.conf 35 | 36 | EXPOSE 4222 8222 6222 37 | ENTRYPOINT ["C:\\nats-server.exe"] 38 | CMD ["--config", "nats-server.conf"] 39 | -------------------------------------------------------------------------------- /2.11.x/windowsservercore-ltsc2025/nats-server.conf: -------------------------------------------------------------------------------- 1 | # Client port of 4222 on all interfaces 2 | port: 4222 3 | 4 | # HTTP monitoring port 5 | monitor_port: 8222 6 | 7 | # This is for clustering multiple servers together. 8 | cluster { 9 | # It is recommended to set a cluster name 10 | name: "my_cluster" 11 | 12 | # Route connections to be received on any interface on port 6222 13 | port: 6222 14 | 15 | # Routes are protected, so need to use them with --routes flag 16 | # e.g. --routes=nats-route://ruser:T0pS3cr3t@otherdockerhost:6222 17 | authorization { 18 | user: ruser 19 | password: T0pS3cr3t 20 | timeout: 2 21 | } 22 | 23 | # Routes are actively solicited and connected to from this server. 24 | # This Docker image has none by default, but you can pass a 25 | # flag to the nats-server docker image to create one to an existing server. 26 | routes = [] 27 | } 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # nats-docker 2 | 3 | [![License][License-Image]][License-Url] 4 | 5 | This is the repository for building the official [NATS server Docker images]. If you 6 | just want to use NATS server, then head over to [Docker Hub]. You don't need 7 | this repository. 8 | 9 | The rest of this readme is for image maintainers. 10 | 11 | ## Directory structure 12 | 13 | The directories are structured in a way such that each NATS server release has 14 | a directory. Each release version has a number of base image variants, such as 15 | scratch on Linux or nanoserver on Windows. 16 | 17 | ``` 18 | nats-docker/ 19 | ├── 2.9.x 20 | │   ├── image variant 1 21 | └───└── image variant 2 22 | ├── 2.10.x 23 | │   ├── image variant 1 24 | └───└── image variant 2 25 | ``` 26 | 27 | For the most part, image variant Dockerfiles will download the official NATS 28 | server [release binaries] when building the server image and `COPY` a default 29 | configuration file. 30 | 31 | The Linux scratch image is a little special. It copies a server binary from the 32 | Alpine image because the scratch image doesn't come with any tools to download 33 | and untar binaries. 34 | 35 | ## Updating NATS server version 36 | 37 | First, make sure you've published a new NATS server git tag and make sure the 38 | [release binaries] and SHASUMS are ready to download. 39 | 40 | Next, run the command below. This will update the version and hash of the NATS 41 | server. If this is a patch release, it will update the existing directory. 42 | However, if it is a minor or major version, it will create the new directory 43 | (if required) from the latest minor version. 44 | 45 | ``` 46 | usage: ./update.py 47 | ./update.py 2.10.0 48 | ``` 49 | 50 | You can check what changed with `git diff`. 51 | 52 | ## Manual updates 53 | 54 | This script doesn't update everything. Here are some other things you 55 | may or may not want to update. 56 | 57 | - The Ubuntu host version used for CI. 58 | - The Windows host versions used for CI. 59 | - The Alpine version 60 | 61 | After you've updated everything that needs updating. Submit a PR to this repo. 62 | Make sure CI passes. 63 | 64 | ## Publishing on Docker Hub 65 | 66 | To publish your new changes to Docker Hub. Head over to 67 | [docker-library/official-images]. You'll need to update the [nats IMF] file. 68 | 69 | IMF stands for Internet Message Format. It's the format that Docker chose to 70 | declare images, instead of something like YAML. 71 | 72 | You'll need to update the git commit in this file. 73 | 74 | ``` 75 | GitCommit: 710f0ed18645d78e97fa7fd8cdf9b80dbe936eb6 76 | ``` 77 | 78 | Also handy to know, if you're testing and haven't merged your PR in 79 | nats-io/nats-docker. You can tell Docker to pull a commit from a different 80 | branch like this. 81 | 82 | ``` 83 | GitFetch: refs/heads/mybranch 84 | GitCommit: 710f0ed18645d78e97fa7fd8cdf9b80dbe936eb6 85 | ``` 86 | 87 | Docker images will be built in the order they're specified in the IMF file. 88 | This detail is very important because Windows images and the scratch image 89 | depend on this behavior. Nanoserver images must be built after servercore 90 | images. Scratch must be built after Alpine. 91 | 92 | ``` 93 | Tags: 2.1.0-windowsservercore-1809, windowsservercore-1809 94 | Architectures: windows-amd64 95 | Directory: 2.1.0/windowsservercore-1809 96 | Constraints: windowsservercore-1809 97 | 98 | Tags: 2.1.0-nanoserver-1809, nanoserver-1809 99 | Architectures: windows-amd64 100 | Directory: 2.1.0/nanoserver-1809 101 | Constraints: nanoserver-1809, windowsservercore-1809 102 | ``` 103 | 104 | The names of the images also have to be consistent with the rest of the 105 | official images. Make sure the names match existing image names. For example, 106 | it should be `2.1.0-windowsservercore-1809`, not `2.1.0-windowsservercore1809`, 107 | not `2.1.0-servercore-1809`. 108 | 109 | [Docker Hub]: https://hub.docker.com/_/nats 110 | [docker-library/official-images]: https://github.com/docker-library/official-images 111 | [License-Image]: https://img.shields.io/badge/License-Apache2-blue.svg 112 | [License-Url]: https://www.apache.org/licenses/LICENSE-2.0 113 | [nats IMF]: https://github.com/docker-library/official-images/blob/master/library/nats 114 | [NATS server Docker images]: https://hub.docker.com/_/nats 115 | [release binaries]: https://github.com/nats-io/nats-server/releases 116 | -------------------------------------------------------------------------------- /update.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import re 5 | import sys 6 | import glob 7 | import shutil 8 | import typing 9 | import urllib.request 10 | 11 | semver_str = r"([0-9]+)\.([0-9]+)\.([0-9]+)(-(preview|rc|RC)\.([0-9]+))?" 12 | sha256_str = r"[A-Fa-f0-9]{64}" 13 | default_sha256 = "0000000000000000000000000000000000000000000000000000000000000000" 14 | 15 | 16 | # Update the NATS_SERVER env variable across applicable files. 17 | def update_env_var(base_dir: str, new_ver: str): 18 | files = [ 19 | f"./{base_dir}/windowsservercore-ltsc2022/Dockerfile", 20 | f"./{base_dir}/windowsservercore-ltsc2025/Dockerfile", 21 | f"./{base_dir}/tests/build-images.sh", 22 | f"./{base_dir}/tests/run-images.sh", 23 | f"./{base_dir}/tests/build-images-ltsc2022.ps1", 24 | f"./{base_dir}/tests/build-images-ltsc2025.ps1", 25 | f"./{base_dir}/tests/run-images-ltsc2022.ps1", 26 | f"./{base_dir}/tests/run-images-ltsc2025.ps1", 27 | ] + glob.glob(f"./{base_dir}/alpine*/Dockerfile") 28 | 29 | r = re.compile(r"(NATS_SERVER )" + semver_str) 30 | 31 | for f in files: 32 | with open(f, "r") as fd: 33 | data = fd.read() 34 | 35 | with open(f, "w") as fd: 36 | fd.write(r.sub(f"\g<1>{new_ver}", data)) 37 | 38 | 39 | # Update the nats:x.y.z tag across applicable files. 40 | def update_tag_var(base_dir: str, new_ver: str): 41 | files = [ 42 | f"./{base_dir}/nanoserver-ltsc2022/Dockerfile", 43 | f"./{base_dir}/nanoserver-ltsc2025/Dockerfile", 44 | f"./{base_dir}/scratch/Dockerfile", 45 | ] 46 | 47 | r = re.compile(r"(--from=nats:)" + semver_str) 48 | 49 | for f in files: 50 | with open(f, "r") as fd: 51 | data = fd.read() 52 | 53 | with open(f, "w") as fd: 54 | fd.write(r.sub(f"\g<1>{new_ver}", data)) 55 | 56 | 57 | # Update the nats:x.y.z tag across applicable files. 58 | def update_preview_tag_var(base_dir: str, new_ver: str): 59 | files = [ 60 | f"./{base_dir}/nanoserver-ltsc2022/Dockerfile.preview", 61 | f"./{base_dir}/nanoserver-ltsc2025/Dockerfile.preview", 62 | f"./{base_dir}/scratch/Dockerfile.preview", 63 | ] 64 | 65 | r = re.compile(r"(BASE_IMAGE=nats:)" + semver_str) 66 | 67 | for f in files: 68 | with open(f, "r") as fd: 69 | data = fd.read() 70 | 71 | with open(f, "w") as fd: 72 | fd.write(r.sub(f"\g<1>{new_ver}", data)) 73 | 74 | 75 | # Update the NATS SHASUM across applicable files. 76 | def update_windows_shasums(base_dir: str, new_ver: str, shasums: typing.Dict): 77 | files = [ 78 | f"{base_dir}/windowsservercore-ltsc2022/Dockerfile", 79 | f"{base_dir}/windowsservercore-ltsc2025/Dockerfile", 80 | ] 81 | 82 | key = f"nats-server-v{new_ver}-windows-amd64.zip" 83 | sha = shasums.get(key, default_sha256) 84 | 85 | r = re.compile(r"(NATS_SERVER_SHASUM )" + sha256_str) 86 | 87 | for f in files: 88 | with open(f, "r") as fd: 89 | data = fd.read() 90 | 91 | with open(f, "w") as fd: 92 | fd.write(r.sub(f"\g<1>{sha}", data)) 93 | 94 | 95 | def update_alpine_shasums(base_dir: str, new_ver: str, shasums: typing.Dict): 96 | file = glob.glob(f"{base_dir}/alpine*/Dockerfile")[0] 97 | 98 | with open(file, "r") as fd: 99 | data = fd.read() 100 | 101 | for arch in ("arm64", "arm6", "arm7", "amd64", "386", "s390x", "ppc64le"): 102 | key = f"nats-server-v{new_ver}-linux-{arch}.tar.gz" 103 | arch_sha = shasums.get(key, default_sha256) 104 | r = re.compile(f"(natsArch='{arch}'; )"+r"sha256='" + sha256_str + r"'") 105 | data = r.sub(f"\g<1>sha256='{arch_sha}'", data) 106 | 107 | with open(file, "w") as fd: 108 | fd.write(data) 109 | 110 | 111 | def get_shasums(ver: str) -> typing.Dict: 112 | u = f"https://github.com/nats-io/nats-server/releases/download/v{ver}/SHA256SUMS" 113 | 114 | d = {} 115 | try: 116 | with urllib.request.urlopen(u) as resp: 117 | data = resp.readlines() 118 | 119 | for line in data: 120 | sps = line.split() 121 | if len(sps) != 2: 122 | continue 123 | d[sps[1].decode("utf-8")] = sps[0].decode("utf-8") 124 | except Exception as e: 125 | pass 126 | 127 | return d 128 | 129 | 130 | # Get the base version directory for the new version. 131 | def get_base_version(cdir: str, maj_ver: int, min_ver: int) -> str: 132 | r = re.compile(r"[0-9]+\.[0-9]+\.x") 133 | 134 | base_dir = None 135 | for f in os.listdir(base_dir): 136 | if not r.search(f): 137 | continue 138 | 139 | toks = f.split(".") 140 | if len(toks) != 3: 141 | continue 142 | 143 | # Explicit match on major and minor. 144 | # First precedence. 145 | if int(toks[0]) == maj_ver and int(toks[1]) == min_ver: 146 | return f 147 | 148 | # Directory has prior minor version. 149 | # Second precedence. 150 | if int(toks[0]) == maj_ver and int(toks[1]) == (min_ver - 1): 151 | base_dir = f 152 | 153 | # Directory has prior major version. 154 | # Third precedence. 155 | if not base_dir and int(toks[0]) == (maj_ver - 1): 156 | base_dir = f 157 | 158 | return base_dir 159 | 160 | 161 | def ensure_dir(base_dir: str, maj_ver: int, min_ver: int) -> str: 162 | # Already exists, use that minor directory. 163 | if os.path.exists(f"{maj_ver}.{min_ver}.x"): 164 | return f"{maj_ver}.{min_ver}.x" 165 | 166 | # Create and copy the directory. 167 | shutil.copytree(base_dir, f"{maj_ver}.{min_ver}.x", symlinks=True) 168 | 169 | return f"{maj_ver}.{min_ver}.x" 170 | 171 | 172 | if __name__ == "__main__": 173 | if len(sys.argv) != 2: 174 | print(f"usage: {sys.argv[0]} ") 175 | sys.exit(1) 176 | 177 | new_ver = sys.argv[1] 178 | if not re.compile(semver_str).match(new_ver): 179 | print(f"invalid version: {new_ver}") 180 | sys.exit(1) 181 | 182 | toks = new_ver.split(".") 183 | maj_ver = int(toks[0]) 184 | min_ver = int(toks[1]) 185 | 186 | base_dir = get_base_version(".", maj_ver, min_ver) 187 | if not base_dir: 188 | print(f"unable to find base version for {maj_ver}.{min_ver}.x") 189 | sys.exit(1) 190 | 191 | print(f"base dir: {base_dir}") 192 | print(f"new version: {new_ver}") 193 | 194 | print("downloading binary release shasums...") 195 | shasums = get_shasums(new_ver) 196 | 197 | # Ensure the new directory exists. 198 | base_dir = ensure_dir(base_dir, maj_ver, min_ver) 199 | 200 | print("updating local files...") 201 | update_env_var(base_dir, new_ver) 202 | update_tag_var(base_dir, new_ver) 203 | update_preview_tag_var(base_dir, new_ver) 204 | 205 | update_windows_shasums(base_dir, new_ver, shasums) 206 | update_alpine_shasums(base_dir, new_ver, shasums) 207 | 208 | print("update complete") 209 | --------------------------------------------------------------------------------