zabbix-docker/Dockerfiles/agent/windows/Dockerfile

60 lines
2.4 KiB
Docker
Raw Normal View History

2021-09-16 03:15:22 +02:00
# syntax=docker/dockerfile:1
# escape=`
ARG MAJOR_VERSION=6.0
2022-02-15 11:00:22 +01:00
ARG ZBX_VERSION=${MAJOR_VERSION}.0
ARG BUILD_BASE_IMAGE=zabbix-build-agent:ltsc2022-agent-${ZBX_VERSION}
2021-10-16 17:49:19 +02:00
ARG BASE_IMAGE=mcr.microsoft.com/powershell:lts-nanoserver-ltsc2022
FROM ${BUILD_BASE_IMAGE} as builder
FROM $BASE_IMAGE
ARG MAJOR_VERSION
ARG ZBX_VERSION
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
LABEL org.opencontainers.image.title="Zabbix agent" `
org.opencontainers.image.authors="Alexey Pustovalov <alexey.pustovalov@zabbix.com>" `
org.opencontainers.image.vendor="Zabbix LLC" `
org.opencontainers.image.url="https://zabbix.com/" `
org.opencontainers.image.description="Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications" `
org.opencontainers.image.licenses="GPL v2.0" `
org.opencontainers.image.documentation="https://www.zabbix.com/documentation/${MAJOR_VERSION}/manual/installation/containers" `
org.opencontainers.image.version="${ZBX_VERSION}" `
org.opencontainers.image.source="${ZBX_SOURCES}"
SHELL ["pwsh", "-Command", "$ErrorActionPreference = 'Stop';"]
WORKDIR C:\zabbix\
COPY --from=builder ["C:\\zabbix", "C:\\zabbix"]
COPY [".\\docker-entrypoint.ps1", "C:\\zabbix"]
USER ContainerAdministrator
2021-09-17 01:19:15 +02:00
RUN $env:PATH = [string]::Format('{0}\zabbix\sbin;{0}\zabbix\bin;', $env:SystemDrive) + $env:PATH; `
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); `
`
$env:ZBX_HOME = [string]::Format('{0}\zabbix', $env:SystemDrive); `
[Environment]::SetEnvironmentVariable('ZBX_HOME', $env:ZBX_HOME, [EnvironmentVariableTarget]::Machine);
2021-09-17 01:19:15 +02:00
RUN Set-Location -Path $env:SystemDrive\.; `
`
New-Item -ItemType directory -Path $env:ZBX_HOME\conf\zabbix_agentd.d | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_HOME\enc | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_HOME\modules | Out-Null; `
New-Item -ItemType directory -Path $env:ZBX_HOME\buffer | Out-Null; `
`
net user /add zabbix; `
2021-09-17 01:19:15 +02:00
$acl = Get-Acl -Path $env:ZBX_HOME; `
$ace = New-Object Security.AccessControl.FileSystemAccessRule ('zabbix', 'Modify', 'ContainerInherit, ObjectInherit', 'InheritOnly', 'Allow'); `
$acl.AddAccessRule($ace); `
2021-09-17 01:19:15 +02:00
Set-Acl -AclObject $acl -Path $env:ZBX_HOME;
USER zabbix
EXPOSE 10050/TCP
2021-09-17 01:19:15 +02:00
CMD C:\zabbix\docker-entrypoint.ps1 C:\zabbix\sbin\zabbix_agentd.exe -c C:\zabbix\conf\zabbix_agentd.win.conf -f