2021-09-17 22:35:50 +02:00
|
|
|
# syntax=docker/dockerfile:1
|
|
|
|
# escape=`
|
2023-03-07 09:07:13 +01:00
|
|
|
ARG MAJOR_VERSION=7.0
|
2021-09-17 22:35:50 +02:00
|
|
|
ARG ZBX_VERSION=${MAJOR_VERSION}
|
|
|
|
ARG BUILD_BASE_IMAGE=zabbix-build-base:ltsc2022-agent-${ZBX_VERSION}
|
|
|
|
|
|
|
|
FROM ${BUILD_BASE_IMAGE} as builder
|
|
|
|
|
2024-05-20 06:11:31 +02:00
|
|
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
|
|
|
|
2021-09-17 22:35:50 +02:00
|
|
|
ARG MAJOR_VERSION
|
|
|
|
ARG ZBX_VERSION
|
|
|
|
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
|
2023-12-15 14:38:54 +01:00
|
|
|
ARG GIT_BRANCH=master
|
2021-09-17 22:35:50 +02:00
|
|
|
ARG ZABBIX_VERSION_RC_NUM=2400
|
2024-05-16 09:33:42 +02:00
|
|
|
|
|
|
|
ENV ZBX_SOURCES=$ZBX_SOURCES MAJOR_VERSION=$MAJOR_VERSION ZBX_VERSION=$ZBX_VERSION GIT_BRANCH=${GIT_BRANCH:-$ZBX_VERSION} `
|
2024-05-20 06:11:31 +02:00
|
|
|
ZABBIX_VERSION_RC_NUM=$ZABBIX_VERSION_RC_NUM
|
2021-09-17 22:35:50 +02:00
|
|
|
|
2021-09-18 03:08:26 +02:00
|
|
|
LABEL org.opencontainers.image.title="Zabbix agent build (Windows)" `
|
|
|
|
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
|
2024-05-13 19:31:38 +02:00
|
|
|
org.opencontainers.image.vendor="Zabbix SIA" `
|
2021-09-18 03:08:26 +02:00
|
|
|
org.opencontainers.image.url="https://zabbix.com/" `
|
|
|
|
org.opencontainers.image.description="Zabbix build for agent images based on Windows" `
|
2024-05-13 19:31:38 +02:00
|
|
|
org.opencontainers.image.licenses="AGPL v3.0" `
|
2021-09-18 03:08:26 +02:00
|
|
|
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
|
|
|
|
org.opencontainers.image.version="${ZBX_VERSION}" `
|
2021-09-17 22:35:50 +02:00
|
|
|
org.opencontainers.image.source="${ZBX_SOURCES}"
|
|
|
|
|
|
|
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
|
|
|
|
|
|
|
RUN Set-Location -Path $env:SystemDrive\.; `
|
2024-05-13 10:29:45 +02:00
|
|
|
`
|
2024-05-20 06:11:31 +02:00
|
|
|
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_src | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\sbin | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\bin | Out-Null; `
|
|
|
|
New-Item -ItemType directory -Path $env:SystemDrive\zabbix_output\conf | Out-Null; `
|
|
|
|
`
|
|
|
|
Import-Module (Get-ChildItem $env:VS_PATH -Recurse -File -Filter Microsoft.VisualStudio.DevShell.dll).FullName; `
|
2024-05-16 21:05:20 +02:00
|
|
|
Enter-VsDevShell -VsInstallPath $env:VS_PATH -SkipAutomaticLocation -DevCmdArguments """-arch=$env:BUILD_ARCH"""; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2024-05-16 09:33:42 +02:00
|
|
|
Write-Host ('Checkout GIT {0} ({1}) repository ...' -f $env:ZBX_SOURCES, $env:GIT_BRANCH); `
|
2024-05-20 06:11:31 +02:00
|
|
|
git -c advice.detachedHead=false clone $env:ZBX_SOURCES --branch $env:GIT_BRANCH --depth 1 --single-branch $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
|
|
|
Write-Host ('Building Zabbix {0} version ...' -f $env:ZBX_VERSION); `
|
2024-05-20 06:11:31 +02:00
|
|
|
Set-Location -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION; `
|
2021-09-17 22:35:50 +02:00
|
|
|
$ZbxRevision=(git rev-parse --short HEAD); `
|
|
|
|
(Get-Content include/version.h).replace('{ZABBIX_REVISION}', $ZbxRevision) | Set-Content include/version.h; `
|
2024-05-20 06:11:31 +02:00
|
|
|
Set-Location -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\build\win32\project; `
|
2021-09-17 22:35:50 +02:00
|
|
|
set CL=/MP; `
|
|
|
|
nmake /S -f Makefile `
|
|
|
|
CPU=$env:CPU_MODEL `
|
2024-05-20 06:11:31 +02:00
|
|
|
CFLAGS="""/D CURL_STATICLIB /D HAVE_LIBCURL /I "$env:BUILD_OUTPUT\curl\include" /D ZABBIX_VERSION_REVISION=$ZbxRevision /D HAVE_LIBMODBUS_STATIC /D DEFAULT_CONFIG_FILE=$env:SystemDrive\zabbix\conf\zabbix_agentd.conf""" `
|
2024-05-16 09:33:42 +02:00
|
|
|
PCRE2INCDIR=$env:SystemDrive\build_output\pcre2\include `
|
|
|
|
PCRE2LIBDIR=$env:SystemDrive\build_output\pcre2\lib TLS=openssl `
|
2021-09-17 22:35:50 +02:00
|
|
|
RFLAGS="""/D ZABBIX_VERSION_REVISION=$ZbxRevision /D ZABBIX_VERSION_RC_NUM=$env:ZABBIX_VERSION_RC_NUM""" `
|
2024-05-16 09:33:42 +02:00
|
|
|
TLSINCDIR=$env:BUILD_OUTPUT\openssl\include `
|
|
|
|
TLSLIBDIR=$env:BUILD_OUTPUT\openssl\lib `
|
|
|
|
MODBINCDIR=$env:BUILD_OUTPUT\libmodbus\include `
|
|
|
|
MODBLIBDIR=$env:BUILD_OUTPUT\libmodbus\lib `
|
2024-05-20 06:11:31 +02:00
|
|
|
LIBS="""$env:LIBS Crypt32.lib $env:BUILD_OUTPUT\curl\lib\libcurl_a.lib $env:BUILD_OUTPUT\zlib\lib\zlib.lib""" `
|
2021-10-16 17:49:19 +02:00
|
|
|
all; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2021-10-09 00:00:45 +02:00
|
|
|
Write-Host 'Verifying build ("zabbix_agentd.exe -V") ...'; `
|
2024-05-20 06:56:47 +02:00
|
|
|
& $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agentd.exe -V; `
|
|
|
|
dumpbin /dependents $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agentd.exe; `
|
2021-09-17 22:35:50 +02:00
|
|
|
`
|
2024-05-20 06:56:47 +02:00
|
|
|
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_agentd.exe $env:SystemDrive\zabbix_output\sbin; `
|
|
|
|
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_get.exe $env:SystemDrive\zabbix_output\bin; `
|
|
|
|
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\bin\win64\zabbix_sender.exe $env:SystemDrive\zabbix_output\bin; `
|
|
|
|
Copy-Item -Path $env:SystemDrive\zabbix_src\zabbix-$env:ZBX_VERSION\conf\zabbix_agentd.win.conf $env:SystemDrive\zabbix_output\conf\zabbix_agentd.conf; `
|
2021-09-17 22:35:50 +02:00
|
|
|
Write-Host 'Zabbix binaries are compiled...';
|