From 682db5f95a81fcb14ae1eece7a7ae4f06da4fb4d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 23 Jun 2020 16:12:29 +0200 Subject: [PATCH] Dockerfile: run apache2 w/ mod_php and Icinga Web 2 --- Dockerfile | 9 ++++++++- action-base.Dockerfile | 2 +- action.Dockerfile | 2 +- action.bash | 2 ++ deps.Dockerfile | 20 ++++++++++++++++++++ icingaweb2.patch | 26 ++++++++++++++++++++++++++ 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 deps.Dockerfile create mode 100644 icingaweb2.patch diff --git a/Dockerfile b/Dockerfile index 524e6cd..881f086 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1 +1,8 @@ -FROM debian:buster-slim +FROM icinga/icingaweb2-deps + +COPY icingaweb2 /usr/share/icingaweb2 +RUN ["ln", "-vs", "/usr/share/icingaweb2/packages/files/apache/icingaweb2.conf", "/etc/apache2/conf-enabled/"] +RUN ["ln", "-vs", "/usr/share/icingaweb2/bin/icingacli", "/usr/local/bin/"] + +USER www-data +CMD ["bash", "-eo", "pipefail", "-c", ". /etc/apache2/envvars; exec apache2 -DFOREGROUND"] diff --git a/action-base.Dockerfile b/action-base.Dockerfile index 748c130..7e3011f 100644 --- a/action-base.Dockerfile +++ b/action-base.Dockerfile @@ -27,7 +27,7 @@ ADD action-base.list /etc/apt/sources.list.d/docker.list RUN apt-get update ;\ apt-get install --no-install-{recommends,suggests} -y \ - composer docker-ce-cli git nodejs php7.3-zip ;\ + composer docker-ce-cli git nodejs patch php7.3-zip ;\ apt-get clean ;\ rm -vrf /var/lib/apt/lists/* diff --git a/action.Dockerfile b/action.Dockerfile index 9d75af1..ddf84cf 100644 --- a/action.Dockerfile +++ b/action.Dockerfile @@ -1,5 +1,5 @@ FROM icinga/icingaweb2-builder -COPY action.bash Dockerfile get-mods.sh / +COPY action.bash Dockerfile get-mods.sh icingaweb2.patch / CMD ["/action.bash"] diff --git a/action.bash b/action.bash index 3f442d2..a57bd9c 100755 --- a/action.bash +++ b/action.bash @@ -21,6 +21,8 @@ mkimg () { popd done + patch -d icingaweb2 -p0 < /icingaweb2.patch + docker build -f /Dockerfile -t "${TARGET}:$TAG" . STATE_isPost=1 node /actions/checkout/dist/index.js diff --git a/deps.Dockerfile b/deps.Dockerfile new file mode 100644 index 0000000..bc0db44 --- /dev/null +++ b/deps.Dockerfile @@ -0,0 +1,20 @@ +FROM debian:buster-slim + +RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y locales; apt-get clean; rm -vrf /var/lib/apt/lists/*"] +RUN ["perl", "-pi", "-e", "if (/\\bUTF-8$/) { s/^# *// }", "/etc/locale.gen"] +RUN ["locale-gen", "-j", "4"] + +RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y apache2 libapache2-mod-php7.3 php-{imagick,redis} php7.3-{bcmath,bz2,common,curl,dba,enchant,gd,gmp,imap,interbase,intl,json,ldap,mbstring,mysql,odbc,opcache,pgsql,pspell,readline,recode,snmp,soap,sqlite3,sybase,tidy,xml,xmlrpc,xsl,zip}; apt-get clean; rm -vrf /var/lib/apt/lists/*"] + +RUN ["a2enmod", "rewrite"] +RUN ["ln", "-vsf", "/dev/stdout", "/var/log/apache2/access.log"] +RUN ["ln", "-vsf", "/dev/stderr", "/var/log/apache2/error.log"] +RUN ["ln", "-vsf", "/dev/stdout", "/var/log/apache2/other_vhosts_access.log"] + +RUN ["perl", "-pi", "-e", "if (/Listen/) { s/80/8080/ }", "/etc/apache2/ports.conf"] +RUN ["perl", "-pi", "-e", "if (/VirtualHost/) { s/80/8080/ }", "/etc/apache2/sites-available/000-default.conf"] +EXPOSE 8080 + +RUN ["chmod", "o+x", "/var/log/apache2"] +RUN ["chown", "www-data:www-data", "/var/run/apache2"] +RUN ["install", "-o", "www-data", "-g", "www-data", "-d", "/etc/icingaweb2"] diff --git a/icingaweb2.patch b/icingaweb2.patch new file mode 100644 index 0000000..dda100f --- /dev/null +++ b/icingaweb2.patch @@ -0,0 +1,26 @@ +--- packages/files/apache/icingaweb2.conf ++++ packages/files/apache/icingaweb2.conf +@@ -1,4 +1,4 @@ +-Alias /icingaweb2 "/usr/share/icingaweb2/public" ++Alias / "/usr/share/icingaweb2/public/" + + # Remove comments if you want to use PHP FPM and your Apache version is older than 2.4 + # +@@ -34,7 +34,7 @@ Alias /icingaweb2 "/usr/share/icingaweb2/public" + + + RewriteEngine on +- RewriteBase /icingaweb2/ ++ RewriteBase / + RewriteCond %{REQUEST_FILENAME} -s [OR] + RewriteCond %{REQUEST_FILENAME} -l [OR] + RewriteCond %{REQUEST_FILENAME} -d +@@ -44,7 +44,7 @@ Alias /icingaweb2 "/usr/share/icingaweb2/public" + + + DirectoryIndex error_norewrite.html +- ErrorDocument 404 /icingaweb2/error_norewrite.html ++ ErrorDocument 404 /error_norewrite.html + + + # Remove comments if you want to use PHP FPM and your Apache version