FROM debian:11-slim

ARG ZABBIX_URL=https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-3%2Bdebian11_all.deb


WORKDIR /app
RUN chmod 777 /app

RUN apt update -y
RUN apt upgrade -y
RUN apt install locales -y
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN apt install ca-certificates wget curl neofetch nano vim -y --no-install-recommends

RUN wget $ZABBIX_URL
RUN dpkg -i zabbix-release*.deb
RUN rm zabbix-release*.deb
RUN apt update -y
RUN apt install php php-fpm -y --no-install-recommends
RUN apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts -y --no-install-recommends
#RUN apt purge mysql* mariadb* -y
RUN apt auto-remove -y
RUN apt update -y
RUN apt upgrade -y

COPY startservices.sh .
RUN chmod +x startservices.sh
RUN rm -v /etc/nginx/sites-enabled/default
RUN rm -v /usr/share/zabbix/conf/zabbix.conf.php
RUN ln -sv /etc/zabbix/web/zabbix.conf.php /usr/share/zabbix/conf/zabbix.conf.php
RUN mkdir /run/php/
RUN mkdir /run/zabbix/
RUN chmod 777 /run/zabbix/
#Start Services
CMD ["./startservices.sh"]
