zabbix-docker/snmptraps/alpine/Dockerfile
2020-02-20 18:24:58 +02:00

78 lines
2.9 KiB
Docker

FROM alpine:3.11
ARG APK_FLAGS_PERSISTENT="--clean-protected --no-cache"
ARG APK_FLAGS_DEV="--no-cache"
ARG MAJOR_VERSION=5.0
ARG ZBX_VERSION=${MAJOR_VERSION}
ARG ZBX_SOURCES=https://git.zabbix.com/scm/zbx/zabbix.git
ENV TERM=xterm ZBX_VERSION=${ZBX_VERSION} ZBX_SOURCES=${ZBX_SOURCES} \
MIBDIRS=/usr/share/snmp/mibs:/var/lib/zabbix/mibs MIBS=+ALL
LABEL org.opencontainers.image.title="zabbix-snmptraps-alpine" \
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 server with MySQL database support" \
org.opencontainers.image.licenses="GPL v2.0" \
org.opencontainers.image.documentation="Zabbix SNMP traps receiver" \
org.opencontainers.image.version="${ZBX_VERSION}" \
org.opencontainers.image.source="https://anonscm.debian.org/gitweb/?p=collab-maint/snmptrapfmt.git"
STOPSIGNAL SIGTERM
COPY ["snmptrapfmt_1.14+nmu1ubuntu2.tar.gz", "/tmp/"]
RUN set -eux && \
addgroup zabbix && \
adduser -S \
-D -G zabbix \
-h /var/lib/zabbix/ \
zabbix && \
apk update && \
apk add ${APK_FLAGS_PERSISTENT} \
net-snmp \
supervisor && \
apk add ${APK_FLAGS_DEV} --virtual build-dependencies \
alpine-sdk \
autoconf \
automake \
libnsl-dev \
net-snmp-dev && \
mkdir -p /var/lib/zabbix && \
mkdir -p /var/lib/zabbix/snmptraps && \
mkdir -p /var/lib/zabbix/mibs && \
chown --quiet -R zabbix:root /var/lib/zabbix && \
cd /tmp/ && \
tar -zxvf snmptrapfmt_1.14+nmu1ubuntu2.tar.gz && \
cd /tmp/snmptrapfmt-1.14+nmu1ubuntu1/ && \
patch -p1 < ./patches/makefile.patch && \
make -j"$(nproc)" -s && \
cp snmptrapfmthdlr /usr/sbin/snmptrapfmthdlr && \
cp snmptrapfmt /usr/sbin/snmptrapfmt && \
cp snmptrapfmt.conf /etc/snmp/snmptrapfmt.conf && \
echo "disableAuthorization yes" >> "/etc/snmp/snmptrapd.conf" && \
echo "traphandle default /usr/sbin/snmptrapfmthdlr" >> "/etc/snmp/snmptrapd.conf" && \
sed -i \
-e "/^VARFMT=/s/=.*/=\"%n %v \"/" \
-e '/^LOGFMT=/s/=.*/=\"$x ZBXTRAP $R $G $S $e $*\"/' \
-e "/^LOGFILE=/s/=.*/=\"\/var\/lib\/zabbix\/snmptraps\/snmptraps.log\"/" \
"/etc/snmp/snmptrapfmt.conf" && \
rm -rf /tmp/snmptrapfmt_1.14+nmu1ubuntu2.tar.gz && \
rm -rf /tmp/snmptrapfmt-1.14+nmu1ubuntu1/ && \
apk del --purge --no-network \
build-dependencies && \
rm -rf /var/cache/apk/*
EXPOSE 162/UDP
WORKDIR /var/lib/zabbix/snmptraps/
VOLUME ["/var/lib/zabbix/snmptraps", "/var/lib/zabbix/mibs"]
COPY ["conf/etc/supervisor/", "/etc/supervisor/"]
COPY ["conf/etc/logrotate.d/zabbix_snmptraps", "/etc/logrotate.d/"]
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]