From 9ea23aaef586a2a47acb9565d22fe4a219ef3e46 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Tue, 5 Oct 2021 23:24:41 +0200 Subject: [PATCH] Agent2 build fix on Alpine, OEL and Ubuntu --- Dockerfiles/agent2/alpine/Dockerfile | 2 +- Dockerfiles/agent2/ol/Dockerfile | 27 ++++++++++++++++++++++++++- Dockerfiles/agent2/ubuntu/Dockerfile | 3 ++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Dockerfiles/agent2/alpine/Dockerfile b/Dockerfiles/agent2/alpine/Dockerfile index 1bc81b640..c159139eb 100644 --- a/Dockerfiles/agent2/alpine/Dockerfile +++ b/Dockerfiles/agent2/alpine/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.12 +FROM alpine:3.14 LABEL org.opencontainers.image.title="Zabbix agent 2" \ org.opencontainers.image.authors="Alexey Pustovalov " \ diff --git a/Dockerfiles/agent2/ol/Dockerfile b/Dockerfiles/agent2/ol/Dockerfile index 6f973126c..c01872f3f 100644 --- a/Dockerfiles/agent2/ol/Dockerfile +++ b/Dockerfiles/agent2/ol/Dockerfile @@ -56,22 +56,46 @@ RUN set -eux && REPOLIST="ol8_baseos_latest,ol8_appstream" && \ automake \ pcre-devel \ libcurl-devel \ - go \ make \ openssl-devel \ openldap-devel \ git \ + wget \ + tar \ gcc" && \ microdnf -y install --setopt=install_weak_deps=0 --best \ --nodocs dnf && \ dnf -y install --disablerepo "*" --enablerepo "${REPOLIST}" --setopt=install_weak_deps=False --best \ --setopt=tsflags=nodocs ${INSTALL_PKGS} && \ + ARCH_SUFFIX="$(arch)"; \ + case "$ARCH_SUFFIX" in \ + x86_64) \ + url='https://dl.google.com/go/go1.17.1.linux-amd64.tar.gz'; \ + sha256='dab7d9c34361dc21ec237d584590d72500652e7c909bf082758fb63064fca0ef'; \ + ;; \ + aarch64) \ + url='https://dl.google.com/go/go1.17.1.linux-arm64.tar.gz'; \ + sha256='53b29236fa03ed862670a5e5e2ab2439a2dc288fe61544aa392062104ac0128c'; \ + ;; \ + *) echo "Unknown ARCH_SUFFIX=${ARCH_SUFFIX-}"; exit 1 ;; \ + esac; \ + wget -O go.tgz.asc "$url.asc" && \ + wget -O go.tgz "$url" --progress=dot:giga && \ + echo "$sha256 *go.tgz" | sha256sum -c - && \ + GNUPGHOME="$(mktemp -d)"; export GNUPGHOME; \ + gpg --batch --keyserver keyserver.ubuntu.com --recv-keys 'EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796' && \ + gpg --batch --verify go.tgz.asc go.tgz && \ + gpgconf --kill all && \ + rm -rf "$GNUPGHOME" go.tgz.asc && \ + tar -C /usr/local -xzf go.tgz && \ + rm go.tgz && \ cd /tmp/ && \ git -c advice.detachedHead=false clone ${ZBX_SOURCES} --branch ${ZBX_VERSION} --depth 1 --single-branch zabbix-${ZBX_VERSION} && \ cd /tmp/zabbix-${ZBX_VERSION} && \ zabbix_revision=`git rev-parse --short HEAD` && \ sed -i "s/{ZABBIX_REVISION}/$zabbix_revision/g" src/go/pkg/version/version.go && \ ./bootstrap.sh && \ + export PATH=/usr/local/go/bin:$PATH && \ export CFLAGS="-fPIC -pie -Wl,-z,relro -Wl,-z,now" && \ export GOPATH=/tmp/zabbix-${ZBX_VERSION}/go && \ ./configure \ @@ -101,6 +125,7 @@ RUN set -eux && REPOLIST="ol8_baseos_latest,ol8_appstream" && \ chown --quiet -R zabbix:root /etc/zabbix/ /var/lib/zabbix/ && \ chgrp -R 0 /etc/zabbix/ /var/lib/zabbix/ && \ chmod -R g=u /etc/zabbix/ /var/lib/zabbix/ && \ + rm -rf /usr/local/go && \ rm -rf /var/cache/yum /var/lib/yum/yumdb/* /usr/lib/udev/hwdb.d/* && \ rm -rf /var/cache/dnf /etc/udev/hwdb.bin /root/.pki diff --git a/Dockerfiles/agent2/ubuntu/Dockerfile b/Dockerfiles/agent2/ubuntu/Dockerfile index e6deb5f26..ee221289f 100644 --- a/Dockerfiles/agent2/ubuntu/Dockerfile +++ b/Dockerfiles/agent2/ubuntu/Dockerfile @@ -69,13 +69,14 @@ RUN set -eux && \ pkg-config \ git \ g++ \ - golang && \ + golang-1.16 && \ cd /tmp/ && \ git -c advice.detachedHead=false clone ${ZBX_SOURCES} --branch ${ZBX_VERSION} --depth 1 --single-branch zabbix-${ZBX_VERSION} && \ cd /tmp/zabbix-${ZBX_VERSION} && \ zabbix_revision=`git rev-parse --short HEAD` && \ sed -i "s/{ZABBIX_REVISION}/$zabbix_revision/g" include/version.h && \ ./bootstrap.sh && \ + PATH=/usr/lib/go-1.16/bin:$PATH && \ export CFLAGS="-fPIC -pie -Wl,-z,relro -Wl,-z,now" && \ ./configure \ --datadir=/usr/lib \