Updated Alpine images

This commit is contained in:
Alexey Pustovalov
2020-04-26 00:15:19 +03:00
43 changed files with 331 additions and 2087 deletions

View File

@ -4,22 +4,21 @@ LABEL org.opencontainers.image.title="Zabbix web-interface (Apache, MySQL)" \
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="abbix web-interface based on Apache2 web server with MySQL database support" \
org.opencontainers.image.description="Zabbix web-interface based on Apache2 web server with MySQL database support" \
org.opencontainers.image.licenses="GPL v2.0"
STOPSIGNAL SIGTERM
RUN set -eux && \
addgroup -S -g 1000 zabbix && \
addgroup -S -g 1995 zabbix && \
adduser -S \
-D -G zabbix \
-u 999 \
-D -G zabbix -G root \
-u 1997 \
-h /var/lib/zabbix/ \
-H \
zabbix && \
mkdir -p /etc/zabbix && \
mkdir -p /etc/zabbix/web && \
chown --quiet -R zabbix:root /etc/zabbix && \
apk add --clean-protected --no-cache \
apache2 \
bash \
@ -49,9 +48,10 @@ RUN set -eux && \
-e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' \
"/etc/apache2/httpd.conf" && \
sed -ri \
-e 's!^(\s*PidFile)\s+\S+!\1 "/var/run/httpd.pid"!g' \
-e 's!^(\s*PidFile)\s+\S+!\1 "/tmp/httpd.pid"!g' \
"/etc/apache2/conf.d/mpm.conf" && \
rm -f "/var/run/apache2/apache2.pid" && \
sed -i 's/Listen 80/Listen 8080/g' /etc/apache2/httpd.conf && \
rm -rf "/var/run/apache2/" && \
rm -rf /var/cache/apk/*
ARG MAJOR_VERSION=5.0
@ -64,6 +64,8 @@ LABEL org.opencontainers.image.documentation="https://www.zabbix.com/documentati
org.opencontainers.image.version="${ZBX_VERSION}" \
org.opencontainers.image.source="${ZBX_SOURCES}"
COPY ["conf/etc/", "/etc/"]
RUN set -eux && \
apk add --no-cache --virtual build-dependencies \
gettext \
@ -78,22 +80,26 @@ RUN set -eux && \
rm -rf tests && \
./locale/make_mo.sh && \
ln -s "/etc/zabbix/web/zabbix.conf.php" "/usr/share/zabbix/conf/zabbix.conf.php" && \
chown --quiet -R zabbix:root /etc/zabbix/ /usr/share/zabbix/conf/ && \
chgrp -R 0 /etc/zabbix/ /usr/share/zabbix/conf/ && \
chmod -R g=u /etc/zabbix/ /usr/share/zabbix/conf/ && \
chown --quiet -R zabbix:root /etc/apache2/ /etc/php7/ && \
chgrp -R 0 /etc/apache2/ /etc/php7/ && \
chmod -R g=u /etc/apache2/ /etc/php7/ && \
apk del --purge --no-network \
build-dependencies && \
rm -rf /var/cache/apk/*
EXPOSE 80/TCP 443/TCP
EXPOSE 8080/TCP 8443/TCP
WORKDIR /usr/share/zabbix
VOLUME ["/etc/ssl/apache2"]
COPY ["conf/etc/zabbix/apache.conf", "/etc/zabbix/"]
COPY ["conf/etc/zabbix/apache_ssl.conf", "/etc/zabbix/"]
COPY ["conf/etc/zabbix/web/zabbix.conf.php", "/etc/zabbix/web/"]
COPY ["conf/etc/php7/conf.d/99-zabbix.ini", "/etc/php7/conf.d/"]
COPY ["docker-entrypoint.sh", "/usr/bin/"]
USER 1997
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

View File

@ -6,4 +6,3 @@ max_input_time=300
; always_populate_raw_post_data=-1
max_input_vars=10000
; date.timezone=Europe/Riga
; session.save_path=/var/lib/php5

View File

@ -1,4 +1,4 @@
<VirtualHost *:80>
<VirtualHost *:8080>
DocumentRoot /usr/share/zabbix/
ServerName zabbix
DirectoryIndex index.php

View File

@ -1,10 +1,10 @@
LoadModule ssl_module modules/mod_ssl.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
Listen 443
Listen 8443
<IfModule mod_ssl.c>
<VirtualHost *:443>
<VirtualHost *:8443>
SSLEngine on
DocumentRoot /usr/share/zabbix/

View File

@ -121,7 +121,7 @@ update_config_var() {
}
# Check prerequisites for MySQL database
check_variables_mysql() {
check_variables() {
: ${DB_SERVER_HOST:="mysql-server"}
: ${DB_SERVER_PORT:="3306"}
USE_DB_ROOT_USER=false
@ -156,7 +156,7 @@ check_variables_mysql() {
DB_SERVER_DBNAME=${MYSQL_DATABASE:-"zabbix"}
}
check_db_connect_mysql() {
check_db_connect() {
echo "********************"
echo "* DB_SERVER_HOST: ${DB_SERVER_HOST}"
echo "* DB_SERVER_PORT: ${DB_SERVER_PORT}"
@ -180,17 +180,7 @@ check_db_connect_mysql() {
done
}
mysql_query() {
query=$1
local result=""
result=$(mysql --silent --skip-column-names -h ${DB_SERVER_HOST} -P ${DB_SERVER_PORT} \
-u ${DB_SERVER_ROOT_USER} --password="${DB_SERVER_ROOT_PASS}" -e "$query")
echo $result
}
prepare_web_server_apache() {
prepare_web_server() {
APACHE_SITES_DIR=/etc/apache2/conf.d
echo "** Adding Zabbix virtual host (HTTP)"
@ -257,18 +247,34 @@ prepare_zbx_web_config() {
prepare_web() {
echo "** Preparing Zabbix web-interface"
check_variables_mysql
check_db_connect_mysql
prepare_web_server_apache
check_variables
check_db_connect
prepare_web_server
prepare_zbx_web_config
}
#################################################
if [ "$1" == '/usr/sbin/httpd' ]; then
prepare_web
echo "** Deploying Zabbix web-interface (Apache) with MySQL database"
prepare_system
prepare_web
clear_deploy
echo "########################################################"
if [ "$1" != "" ]; then
echo "** Executing '$@'"
exec "$@"
elif [ -f "/usr/bin/supervisord" ]; then
echo "** Executing supervisord"
exec /usr/bin/supervisord -c /etc/supervisor/supervisord.conf
else
echo "Unknown instructions. Exiting..."
exit 1
fi
exec "$@"
#################################################