From 19f680a8650f508094e8f47eb3b7417dc4a85e6a Mon Sep 17 00:00:00 2001 From: Robert Schumann Date: Wed, 10 Aug 2022 00:08:41 +0200 Subject: [PATCH] fix latest changes to viewer and parser * new dependency postgres and PDO * php8 compatible --- Dockerfile | 29 ++++++++++++++++--- manifest/entrypoint.sh | 6 ++-- manifest/usr/bin/dmarcts-report-parser.conf | 1 + .../viewer/dmarcts-report-viewer-config.php | 1 + 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 10974c7..4721bb2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG UPSTREAM_IMAGE=trafex/alpine-nginx-php7:2.0.2 +ARG UPSTREAM_IMAGE=trafex/php-nginx:2.6.0 FROM $UPSTREAM_IMAGE @@ -14,8 +14,28 @@ WORKDIR / COPY ./manifest/ / RUN set -x \ - && apk update \ - && apk add bash expat-dev mariadb-dev mariadb-client mariadb-connector-c openssl openssl-dev gzip wget perl-utils g++ make perl-dev tzdata \ + && apk add -U \ + bash \ + expat-dev \ + g++ \ + gzip \ + libpq \ + libpq-dev \ + make \ + mariadb-client \ + mariadb-connector-c \ + mariadb-dev \ + musl-obstack \ + musl-obstack-dev \ + openssl \ + openssl-dev \ + perl-dev \ + perl-utils \ + php81-pdo \ + php81-pdo_mysql \ + php81-pdo_pgsql \ + tzdata \ + wget \ && wget -4 -q --no-check-certificate -O parser.zip $REPORT_PARSER_SOURCE \ && wget -4 -q --no-check-certificate -O viewer.zip $REPORT_VIEWER_SOURCE \ && unzip parser.zip && cp -av dmarcts-report-parser-master/* /usr/bin/ && rm -vf parser.zip && rm -rvf dmarcts-report-parser-master \ @@ -44,11 +64,12 @@ RUN set -x \ XML::Simple \ DBI \ DBD::mysql \ + DBD::Pg \ Socket \ Socket6 \ PerlIO::gzip \ ; do cpan install $i; done \ - && apk del mariadb-dev expat-dev openssl-dev perl-dev g++ make + && apk del mariadb-dev expat-dev openssl-dev perl-dev g++ make musl-obstack-dev libpq-dev HEALTHCHECK --interval=1m --timeout=3s CMD curl --silent --fail http://127.0.0.1:80/fpm-ping diff --git a/manifest/entrypoint.sh b/manifest/entrypoint.sh index 87244e7..b0931f3 100755 --- a/manifest/entrypoint.sh +++ b/manifest/entrypoint.sh @@ -16,11 +16,13 @@ procs=$(cat /proc/cpuinfo | grep processor | wc -l) sed -i -e "s/worker_processes 5/worker_processes $procs/" /etc/nginx/nginx.conf # Copy important env vars for PHP-FPM to access -PHP_ENV_FILE="/etc/php8/php-fpm.d/${PHP_ENV_FILE:-env.conf}" +PHP_ENV_FILE="/etc/php81/php-fpm.d/${PHP_ENV_FILE:-env.conf}" echo '[www]' > "$PHP_ENV_FILE" echo 'user = nginx' >> "$PHP_ENV_FILE" echo 'group = www-data' >> "$PHP_ENV_FILE" -env | grep -e 'REPORT_DB_HOST' -e 'REPORT_DB_PORT' -e 'REPORT_DB_NAME' -e 'REPORT_DB_USER' -e 'REPORT_DB_PASS' | sed "s/\(.*\)=\(.*\)/env[\1] = '\2'/" >> "$PHP_ENV_FILE" +echo 'listen.owner = nginx' >> "$PHP_ENV_FILE" +echo 'listen.group = www-data' >> "$PHP_ENV_FILE" +env | grep -e 'REPORT_DB_TYPE' -e 'REPORT_DB_HOST' -e 'REPORT_DB_PORT' -e 'REPORT_DB_NAME' -e 'REPORT_DB_USER' -e 'REPORT_DB_PASS' | sed "s/\(.*\)=\(.*\)/env[\1] = '\2'/" >> "$PHP_ENV_FILE" # compat from older image where variable was not existing grep -e ^REPORT_DB_PORT "$PHP_ENV_FILE" || echo env[REPORT_DB_PORT] = 3306 >> "$PHP_ENV_FILE" diff --git a/manifest/usr/bin/dmarcts-report-parser.conf b/manifest/usr/bin/dmarcts-report-parser.conf index 3443c04..12bd5de 100644 --- a/manifest/usr/bin/dmarcts-report-parser.conf +++ b/manifest/usr/bin/dmarcts-report-parser.conf @@ -13,6 +13,7 @@ $dbuser = $ENV{'REPORT_DB_USER'}; $dbpass = $ENV{'REPORT_DB_PASS'}; $dbhost = $ENV{'REPORT_DB_HOST'}; # Set the hostname if we can't connect to the local socket. $dbport = $ENV{'REPORT_DB_PORT'} || 3306; +$dbtype = $ENV{'REPORT_DB_TYPE'} || 'mysql'; if(exists $ENV{PARSER_IMAP_SERVER_WITH_PORT} && defined $ENV{PARSER_IMAP_SERVER_WITH_PORT}) { my @server_attr = split ':', $ENV{PARSER_IMAP_SERVER_WITH_PORT}; diff --git a/manifest/var/www/viewer/dmarcts-report-viewer-config.php b/manifest/var/www/viewer/dmarcts-report-viewer-config.php index f6a1d02..b64f764 100644 --- a/manifest/var/www/viewer/dmarcts-report-viewer-config.php +++ b/manifest/var/www/viewer/dmarcts-report-viewer-config.php @@ -4,6 +4,7 @@ // ### configuration ################################################## // #################################################################### +$dbtype=getenv('REPORT_DB_TYPE'); $dbhost=getenv('REPORT_DB_HOST'); $dbport=getenv('REPORT_DB_PORT'); $dbname=getenv('REPORT_DB_NAME');