FROM debian:jessie

MAINTAINER Robin Thoni <robin@rthoni.com>

RUN apt-get update && apt-get -y install\
        wget &&\
        apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN wget http://repo.zabbix.com/zabbix/3.0/debian/pool/main/z/zabbix-release/zabbix-release_3.0-1+jessie_all.deb -O /tmp/zabbix.deb &&\
    dpkg -i /tmp/zabbix.deb

RUN apt-get update && apt-get -y install\
        zabbix-server-pgsql zabbix-get\
        snmp &&\
        apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN chown -R zabbix:zabbix /etc/zabbix &&\
    mkdir -p /var/run/zabbix &&\
    chown zabbix:zabbix /var/run/zabbix/

RUN rm -rf /var/log/* &&\
    mkdir -p /var/log/zabbix/ &&\
    chown zabbix:zabbix /var/log/zabbix/ &&\
    ln -s /dev/stdout /var/log/zabbix/zabbix_server.log

RUN chmod u+s /usr/bin/fping &&\
    chmod u+s /usr/bin/fping6

COPY ./zabbix_server.conf /etc/zabbix/zabbix_server.conf

COPY ./vars-vars /etc/vars-vars

COPY ./vars-files /etc/vars-files

COPY ./run.sh /run.sh

EXPOSE 80

USER zabbix

CMD ["/run.sh"]
