Using plain Windows nanoserver image for agent and agent2 images

This commit is contained in:
Alexey Pustovalov 2025-05-26 11:29:59 +09:00
parent 0101fb79b4
commit 9a0f5773e3
4 changed files with 35 additions and 7 deletions

View File

@ -695,7 +695,7 @@ jobs:
# PowerShell images based on LTSC 2019 and LTSC 2016 do not have "ltsc" prefix # PowerShell images based on LTSC 2019 and LTSC 2016 do not have "ltsc" prefix
$os_tag_suffix=$Env:BASE_BUILD_OS_TAG $os_tag_suffix=$Env:BASE_BUILD_OS_TAG
$os_tag_suffix=$os_tag_suffix -replace "ltsc2019",'1809' # $os_tag_suffix=$os_tag_suffix -replace "ltsc2019",'1809'
$base_image=$Env:OS_BASE_IMAGE_NAME + ':' + $os_tag_suffix $base_image=$Env:OS_BASE_IMAGE_NAME + ':' + $os_tag_suffix
echo "::group::Image tags" echo "::group::Image tags"

View File

@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1 # syntax=docker/dockerfile:1
# escape=` # escape=`
ARG OS_BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022 ARG OS_BASE_IMAGE=mcr.microsoft.com/windows/nanoserver:ltsc2022
ARG MAJOR_VERSION=7.4 ARG MAJOR_VERSION=7.4
ARG ZBX_VERSION=${MAJOR_VERSION} ARG ZBX_VERSION=${MAJOR_VERSION}
@ -30,15 +30,18 @@ LABEL org.opencontainers.image.title="Zabbix agent 2" `
org.opencontainers.image.version="${ZBX_VERSION}" ` org.opencontainers.image.version="${ZBX_VERSION}" `
org.opencontainers.image.source="${ZBX_SOURCES}" org.opencontainers.image.source="${ZBX_SOURCES}"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop';"] COPY --from=builder ["C:\\zabbix-${ZBX_VERSION}-output", "C:\\zabbix"]
COPY --from=builder ["C:\\pwsh", "C:\\Program Files\\PowerShell"]
COPY [".\\docker-entrypoint.ps1", "C:\\zabbix"]
WORKDIR C:\zabbix\ WORKDIR C:\zabbix\
COPY --from=builder ["C:\\zabbix-${ZBX_VERSION}-output", "C:\\zabbix"]
COPY [".\\docker-entrypoint.ps1", "C:\\zabbix"]
USER ContainerAdministrator USER ContainerAdministrator
RUN setx /M PATH "%PATH%;C:\Program Files\PowerShell"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop';"]
RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; ` RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; `
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); ` [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
` `

View File

@ -125,7 +125,6 @@ RUN Set-Location -Path $env:SystemDrive\.; `
Expand-Archive ` Expand-Archive `
-Path $env:TEMP\pwsh.zip ` -Path $env:TEMP\pwsh.zip `
-DestinationPath $env:SystemDrive\pwsh\.; ` -DestinationPath $env:SystemDrive\pwsh\.; `
`
Get-ChildItem -Path $env:SystemDrive\pwsh -Directory | Where-Object { ` Get-ChildItem -Path $env:SystemDrive\pwsh -Directory | Where-Object { `
$_.Name -match '^(cs|de|es|fr|it|ja|ko|pl|pt-BR|ru|tr|zh-Hans|zh-Hant)$' ` $_.Name -match '^(cs|de|es|fr|it|ja|ko|pl|pt-BR|ru|tr|zh-Hans|zh-Hant)$' `
} | Remove-Item -Recurse -Force; ` } | Remove-Item -Recurse -Force; `

View File

@ -7,6 +7,7 @@ ARG PCRE2_VERSION=10.45
ARG OPENSSL_VERSION=3.4.1 ARG OPENSSL_VERSION=3.4.1
ARG GOLANG_VERSION=1.24.3 ARG GOLANG_VERSION=1.24.3
ARG VS_BUILDTOOLS_VERSION=17 ARG VS_BUILDTOOLS_VERSION=17
ARG PWSH_VERSION=7.5.1
ARG MSYSTEM=UCRT64 ARG MSYSTEM=UCRT64
@ -23,6 +24,8 @@ ARG MSYS2_URL=https://api.github.com/repos/msys2/msys2-installer/releases/latest
ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip ARG PCRE2_URL=https://github.com/PhilipHazel/pcre2/releases/download/pcre2-$PCRE2_VERSION/pcre2-$PCRE2_VERSION.zip
ARG OPENSSL_URL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz ARG OPENSSL_URL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz
ARG PWSH_URL=https://github.com/PowerShell/PowerShell/releases/download/v$PWSH_VERSION/PowerShell-$PWSH_VERSION-win-x64.zip
ENV ZBX_VERSION=$ZBX_VERSION ` ENV ZBX_VERSION=$ZBX_VERSION `
BUILD_ARCH=$BUILD_ARCH ` BUILD_ARCH=$BUILD_ARCH `
MINGW_URL=$MINGW_URL VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL VS_BUILDTOOLS_VERSION=$VS_BUILDTOOLS_VERSION GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL ` MINGW_URL=$MINGW_URL VS_BUILDTOOLS_URL=$VS_BUILDTOOLS_URL VS_BUILDTOOLS_VERSION=$VS_BUILDTOOLS_VERSION GOLANG_VERSION=$GOLANG_VERSION MSYS2_URL=$MSYS2_URL `
@ -58,6 +61,17 @@ RUN Set-Location -Path $env:SystemDrive\.; `
New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; ` New-Item -ItemType directory -Path $env:BUILD_OUTPUT -Force | Out-Null; `
New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; ` New-Item -ItemType directory -Path $env:BUILD_SRC -Force | Out-Null; `
` `
Write-Host ('Downloading {0} ...' -f $env:PWSH_URL); `
Invoke-WebRequest -OutFile $env:TEMP\pwsh.zip -Uri $env:PWSH_URL; `
`
$sha256 = '4d3028da81170f8d1cd226614582f0a95d3dd5592127cf87a09e3a3568e51a08'; `
$d_sha256 = (Get-FileHash $env:TEMP\pwsh.zip -Algorithm sha256).Hash; `
Write-Host ('Verifying SHA256 ({0}) ...' -f $sha256); `
if ((Get-FileHash $env:TEMP\pwsh.zip -Algorithm sha256).Hash -ne $sha256) { `
Write-Host ('Checksum PowerShell ({0}) failed!' -f $d_sha256); `
exit 1; `
}; `
`
Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); ` Write-Host ('Downloading {0} ...' -f $env:GOLANG_URL); `
Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; ` Invoke-WebRequest -OutFile $env:TEMP\go_lang.zip -Uri $env:GOLANG_URL; `
` `
@ -97,6 +111,18 @@ RUN Set-Location -Path $env:SystemDrive\.; `
Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); ` Write-Host ('Downloading {0} ...' -f $env:VS_BUILDTOOLS_URL); `
Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; ` Invoke-WebRequest -OutFile $env:TEMP\vs_buildtools.exe $env:VS_BUILDTOOLS_URL; `
` `
Write-Host 'Installing PowerShell...'; `
Expand-Archive `
-Path $env:TEMP\pwsh.zip `
-DestinationPath $env:SystemDrive\pwsh\.; `
Get-ChildItem -Path $env:SystemDrive\pwsh -Directory | Where-Object { `
$_.Name -match '^(cs|de|es|fr|it|ja|ko|pl|pt-BR|ru|tr|zh-Hans|zh-Hant)$' `
} | Remove-Item -Recurse -Force; `
Get-ChildItem -Path $env:SystemDrive\pwsh -Recurse -Include '*.xml' | Where-Object { $_.FullName -notmatch '\\en-US\\' } | Remove-Item -Force; `
Get-ChildItem -Path $env:SystemDrive\pwsh -Recurse -Include '*.resources.dll' | Where-Object { $_.FullName -notmatch '\\en-US\\' } | Remove-Item -Force; `
Write-Host 'Verifying install ("pwsh -V") ...'; `
& $env:SystemDrive\pwsh\pwsh.exe -V; `
`
Write-Host 'Installing Go Lang...'; ` Write-Host 'Installing Go Lang...'; `
Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; ` Expand-Archive -Path $env:TEMP\go_lang.zip -DestinationPath $env:SystemDrive\; `
` `