From 68a1202e2e79e625eb745632b82ee9e7a1d84ae2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 7 Mar 2021 10:32:46 +0300 Subject: [PATCH] add a hack to send fpm children logs to docker-captured stderr --- app/Dockerfile | 10 +++++++--- app/startup.sh | 5 ++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Dockerfile b/app/Dockerfile index 1c6e2c1..970f508 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -9,9 +9,13 @@ RUN apk add --no-cache dcron php8 php8-fpm \ php8-session php8-tokenizer php8-dom php8-fileinfo \ php8-json php8-iconv php8-pcntl php8-posix php8-zip \ php8-openssl git postgresql-client sudo php8-pecl-xdebug rsync && \ - sed -i.bak 's/^listen = 127.0.0.1:9000/listen = 9000/' /etc/php8/php-fpm.d/www.conf && \ - sed -i.bak 's/\(memory_limit =\) 128M/\1 256M/' /etc/php8/php.ini && \ - sed -i.bak 's/;clear_env = .*/clear_env = no/i' /etc/php8/php-fpm.d/www.conf && \ + sed -i 's/\(memory_limit =\) 128M/\1 256M/' /etc/php8/php.ini && \ + sed -i -e 's/^listen = 127.0.0.1:9000/listen = 9000/' \ + -e 's/;\(clear_env\) = .*/\1 = no/i' \ + -e 's/^\(user\|group\) = .*/\1 = app/i' \ + -e 's/;\(php_admin_value\[error_log\]\) = .*/\1 = \/tmp\/error.log/' \ + -e 's/;\(php_admin_flag\[log_errors\]\) = .*/\1 = on/' \ + /etc/php8/php-fpm.d/www.conf && \ mkdir -p /var/www ${SCRIPT_ROOT}/config.d ADD startup.sh ${SCRIPT_ROOT} diff --git a/app/startup.sh b/app/startup.sh index 8538188..b522912 100755 --- a/app/startup.sh +++ b/app/startup.sh @@ -96,5 +96,8 @@ cd $DST_DIR && sudo -E -u app php8 ./update.php --update-schema=force-yes touch $DST_DIR/.app_is_ready -sudo -E -u app /usr/sbin/php-fpm8 -F +rm -f /tmp/error.log && mkfifo /tmp/error.log && chown app:app /tmp/error.log +(tail -q -f /tmp/error.log >> /proc/1/fd/2) & + +exec /usr/sbin/php-fpm8 --nodaemonize --force-stderr