diff --git a/glpi/Dockerfile b/glpi/Dockerfile index 8ee6c41..f1a24cc 100644 --- a/glpi/Dockerfile +++ b/glpi/Dockerfile @@ -131,11 +131,21 @@ COPY --from=builder --chown=www-data:www-data /usr/src/glpi /var/www/glpi RUN mkdir /var/glpi && chown www-data:www-data /var/glpi VOLUME /var/glpi +# make a directory for GLPI logs. +RUN mkdir -p /var/log/glpi && chown www-data:www-data /var/log/glpi + # Define GLPI environment variables ENV \ GLPI_INSTALL_MODE=DOCKER \ GLPI_CONFIG_DIR=/var/glpi/config \ - GLPI_VAR_DIR=/var/glpi/files + GLPI_VAR_DIR=/var/glpi/files \ + GLPI_LOG_DIR=/var/log/glpi + +# disable apache access logs +RUN rm /var/log/apache2/access.log +RUN rm /var/log/apache2/other_vhosts_access.log +RUN ln -sfT /dev/null /var/log/apache2/access.log +RUN ln -sfT /dev/null /var/log/apache2/other_vhosts_access.log # Make startup script executable and executes it as default command. RUN chmod u+x /opt/startup.sh diff --git a/glpi/files/etc/apache2/sites-available/000-default.conf b/glpi/files/etc/apache2/sites-available/000-default.conf index 2d21152..46eb9f2 100644 --- a/glpi/files/etc/apache2/sites-available/000-default.conf +++ b/glpi/files/etc/apache2/sites-available/000-default.conf @@ -2,7 +2,6 @@ DocumentRoot /var/www/glpi/public ErrorLog ${APACHE_LOG_DIR}/error.log - CustomLog ${APACHE_LOG_DIR}/access.log combined Require all granted diff --git a/glpi/files/opt/startup.sh b/glpi/files/opt/startup.sh index f18be04..3a3d052 100644 --- a/glpi/files/opt/startup.sh +++ b/glpi/files/opt/startup.sh @@ -32,9 +32,29 @@ done # Set ACL for www-data user on marketplace directory setfacl -m user:www-data:rwx,group:www-data:rwx "/var/www/glpi/marketplace" +# forward logs files to /proc/1/fd/1 +# see https://stackoverflow.com/a/63713129 +logs=( + "event.log" + "cron.log" + "mail.log" + "php-errors.log" + "sql-errors.log" + "mail-errors.log" + "access-error.log" +) +for log in "${logs[@]}" +do + if [ ! -f /var/log/glpi/$log ]; + then + touch /var/log/glpi/$log + setfacl -m user:www-data:rwx,group:www-data:rwx /var/log/glpi/$log + fi +done +tail -f /var/log/glpi/*.log > /proc/1/fd/1 & + # Run cron service. cron # Run command previously defined in base php-apache Dockerfile. apache2-foreground -