optimized Dockerfile

This commit is contained in:
Shihaam Abdul Rahman 2022-09-13 11:27:35 +05:00
parent 569c5b84d7
commit 68326a760c
Signed by: shihaam
GPG Key ID: 3B007D22E5584980
2 changed files with 44 additions and 17 deletions

View File

@ -1,38 +1,65 @@
FROM debian:11-slim
# Zabbix Repo packge URL
# obtain it from: https://www.zabbix.com/download?zabbix=6.2&os_distribution=debian&os_version=11&components=server_frontend_agent&db=mysql&ws=nginx
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
# Initial update repo and upgrade packges
RUN apt update -y \
&& apt upgrade -y \
&& apt auto-remove -y \
&& apt clean -y
# Language setup
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 apt install locales -y \
&& apt auto-remove -y \
&& apt clean -y
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \
&& locale-gen
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
# Installing basic tools
RUN apt install ca-certificates wget curl nano vim -y --no-install-recommends \
&& apt auto-remove -y \
&& apt clean -y
# Installing Zabbix repo for zabbix tools
RUN wget $ZABBIX_URL \
&& dpkg -i zabbix-release*.deb \
&& rm -v zabbix-release*.deb
# Installing php, nginx and zabbix ## DO NOT CHANGE INSTALL ODER OF THIS, IT WILL INSTALL APACHE2 AND NIGNX IF YOU DO SO!!!
RUN apt update -y \
&& apt install php php-fpm -y --no-install-recommends \
&& apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts -y --no-install-recommends \
&& apt auto-remove -y \
&& apt clean -y
# Final clean up
RUN apt update -y \
&& apt upgrade -y \
&& apt auto-remove -y \
&& apt clean -y
COPY startservices.sh .
RUN chmod +x startservices.sh
# Delete default config files, these will be mounted when running container
RUN rm -v /etc/nginx/sites-enabled/default
RUN rm -v /usr/share/zabbix/conf/zabbix.conf.php
# symlink frontend configs to /etc/zabbix
RUN ln -sv /etc/zabbix/web/zabbix.conf.php /usr/share/zabbix/conf/zabbix.conf.php
#Create dirs and give permission for php and zabbix pid
RUN mkdir /run/php/
RUN mkdir /run/zabbix/
RUN chmod 777 /run/zabbix/
#Start Services
CMD ["./startservices.sh"]

View File

@ -2,7 +2,7 @@ version: '3.5'
services:
#########################
zabbix:
# build: .
build: .
image: zabbix
volumes:
- $PWD/configdir/etc/zabbix/zabbix_server.conf:/etc/zabbix/zabbix_server.conf