diff --git a/README.md b/README.md index aa4aec2..aafab01 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ services: - APP_ADMIN_USER=master - APP_ADMIN_EMAIL=master@mydomain.com - APP_ADMIN_PASS=masterPassword + - APP_LOG=0 networks: - reverse-proxy @@ -74,6 +75,7 @@ services: - APP_ADMIN_USER=master - APP_ADMIN_EMAIL=master@mydomain.com - APP_ADMIN_PASS=masterPassword + - APP_LOG=0 ``` # Environment variables @@ -86,4 +88,5 @@ services: * `APP_SECRET`: The encryption secret for the app. * `APP_ADMIN_USER`: The user name for the first super admin to be created automatically. * `APP_ADMIN_EMAIL`: First super admin email. -* `APP_ADMIN_PASS`: First super admin password. \ No newline at end of file +* `APP_ADMIN_PASS`: First super admin password. +* `APP_LOG`: Pipe kimai2 log to the stdout. \ No newline at end of file diff --git a/apache-alpine/Dockerfile b/apache-alpine/Dockerfile index 6ec0718..37fe4a7 100644 --- a/apache-alpine/Dockerfile +++ b/apache-alpine/Dockerfile @@ -2,7 +2,8 @@ FROM webdevops/php-apache:alpine MAINTAINER Belman Kraul ENV \ - WEB_DOCUMENT_ROOT="/app/public" + WEB_DOCUMENT_ROOT="/app/public" \ + APP_LOG=0 RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ sed "s/prod/dev/g" /app/.env.dist > /app/.env && \ @@ -11,8 +12,12 @@ RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ su -c '/usr/local/bin/composer require zendframework/zend-ldap --working-dir=/app' -l application && \ rm /app/.env && \ touch /app/.env && \ + touch /app/var/log/prod.log && \ + touch /app/var/log/dev.log && \ chown ${APPLICATION_UID}:${APPLICATION_GID} /app/.env COPY ./50-kimai-init.sh /opt/docker/provision/entrypoint.d/50-kimai-init.sh +COPY ./supervisor/kimai-log.sh /opt/docker/bin/service.d/kimai-log.sh +COPY ./supervisor/kimai-log.conf /opt/docker/etc/supervisor.d/kimai-log.conf WORKDIR /app \ No newline at end of file diff --git a/apache-alpine/supervisor/kimai-log.conf b/apache-alpine/supervisor/kimai-log.conf new file mode 100644 index 0000000..e3d001c --- /dev/null +++ b/apache-alpine/supervisor/kimai-log.conf @@ -0,0 +1,14 @@ +[group:kimai-log] +programs=kimai-log +priority=20 + +[program:kimai-log] +command = /opt/docker/bin/service.d/kimai-log.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = false +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/apache-alpine/supervisor/kimai-log.sh b/apache-alpine/supervisor/kimai-log.sh new file mode 100644 index 0000000..61cfec1 --- /dev/null +++ b/apache-alpine/supervisor/kimai-log.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +LOG_PATH="/app/var/log/${APP_ENV}.log" + +# only attempt logging if we have enabled logging +# and the log file exists. +if [ "${APP_LOG}" == "1" ] +then + if [ -f ${LOG_PATH} ] + then + # attempt to tail the log one line at a time. + # the supervisor job will push output to STDOUT. + echo "Now tailing ${LOG_PATH}..." + tail -f -n 1 ${LOG_PATH} + else + echo "Cannot find ${LOG_PATH}. Will now exit..." + fi +fi diff --git a/apache-ubuntu-18.04/Dockerfile b/apache-ubuntu-18.04/Dockerfile index 2807920..32b4c47 100644 --- a/apache-ubuntu-18.04/Dockerfile +++ b/apache-ubuntu-18.04/Dockerfile @@ -2,7 +2,8 @@ FROM webdevops/php-apache:ubuntu-18.04 MAINTAINER Belman Kraul ENV \ - WEB_DOCUMENT_ROOT="/app/public" + WEB_DOCUMENT_ROOT="/app/public" \ + APP_LOG=0 RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ sed "s/prod/dev/g" /app/.env.dist > /app/.env && \ @@ -11,8 +12,12 @@ RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ su -c '/usr/local/bin/composer require zendframework/zend-ldap --working-dir=/app' -l application && \ rm /app/.env && \ touch /app/.env && \ + touch /app/var/log/prod.log && \ + touch /app/var/log/dev.log && \ chown ${APPLICATION_UID}:${APPLICATION_GID} /app/.env COPY ./50-kimai-init.sh /opt/docker/provision/entrypoint.d/50-kimai-init.sh +COPY ./supervisor/kimai-log.sh /opt/docker/bin/service.d/kimai-log.sh +COPY ./supervisor/kimai-log.conf /opt/docker/etc/supervisor.d/kimai-log.conf WORKDIR /app \ No newline at end of file diff --git a/apache-ubuntu-18.04/supervisor/kimai-log.conf b/apache-ubuntu-18.04/supervisor/kimai-log.conf new file mode 100644 index 0000000..e3d001c --- /dev/null +++ b/apache-ubuntu-18.04/supervisor/kimai-log.conf @@ -0,0 +1,14 @@ +[group:kimai-log] +programs=kimai-log +priority=20 + +[program:kimai-log] +command = /opt/docker/bin/service.d/kimai-log.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = false +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/apache-ubuntu-18.04/supervisor/kimai-log.sh b/apache-ubuntu-18.04/supervisor/kimai-log.sh new file mode 100644 index 0000000..61cfec1 --- /dev/null +++ b/apache-ubuntu-18.04/supervisor/kimai-log.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +LOG_PATH="/app/var/log/${APP_ENV}.log" + +# only attempt logging if we have enabled logging +# and the log file exists. +if [ "${APP_LOG}" == "1" ] +then + if [ -f ${LOG_PATH} ] + then + # attempt to tail the log one line at a time. + # the supervisor job will push output to STDOUT. + echo "Now tailing ${LOG_PATH}..." + tail -f -n 1 ${LOG_PATH} + else + echo "Cannot find ${LOG_PATH}. Will now exit..." + fi +fi diff --git a/develop/Dockerfile b/develop/Dockerfile index 2b82f16..efbc51e 100644 --- a/develop/Dockerfile +++ b/develop/Dockerfile @@ -2,17 +2,22 @@ FROM webdevops/php-nginx:alpine MAINTAINER Belman Kraul ENV \ - WEB_DOCUMENT_ROOT="/app/public" + WEB_DOCUMENT_ROOT="/app/public" \ + APP_LOG=0 -RUN git clone https://github.com/kevinpapst/kimai2.git -b install-command /app && \ +RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ sed "s/prod/dev/g" /app/.env.dist > /app/.env && \ chown -R ${APPLICATION_UID}:${APPLICATION_GID} /app && \ su -c '/usr/local/bin/composer install --working-dir=/app --optimize-autoloader' -l application && \ su -c '/usr/local/bin/composer require zendframework/zend-ldap --working-dir=/app' -l application && \ rm /app/.env && \ touch /app/.env && \ + touch /app/var/log/prod.log && \ + touch /app/var/log/dev.log && \ chown ${APPLICATION_UID}:${APPLICATION_GID} /app/.env COPY ./50-kimai-init.sh /opt/docker/provision/entrypoint.d/50-kimai-init.sh +COPY ./supervisor/kimai-log.sh /opt/docker/bin/service.d/kimai-log.sh +COPY ./supervisor/kimai-log.conf /opt/docker/etc/supervisor.d/kimai-log.conf -WORKDIR /app +WORKDIR /app \ No newline at end of file diff --git a/develop/supervisor/kimai-log.conf b/develop/supervisor/kimai-log.conf new file mode 100644 index 0000000..e3d001c --- /dev/null +++ b/develop/supervisor/kimai-log.conf @@ -0,0 +1,14 @@ +[group:kimai-log] +programs=kimai-log +priority=20 + +[program:kimai-log] +command = /opt/docker/bin/service.d/kimai-log.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = false +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/develop/supervisor/kimai-log.sh b/develop/supervisor/kimai-log.sh new file mode 100644 index 0000000..61cfec1 --- /dev/null +++ b/develop/supervisor/kimai-log.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +LOG_PATH="/app/var/log/${APP_ENV}.log" + +# only attempt logging if we have enabled logging +# and the log file exists. +if [ "${APP_LOG}" == "1" ] +then + if [ -f ${LOG_PATH} ] + then + # attempt to tail the log one line at a time. + # the supervisor job will push output to STDOUT. + echo "Now tailing ${LOG_PATH}..." + tail -f -n 1 ${LOG_PATH} + else + echo "Cannot find ${LOG_PATH}. Will now exit..." + fi +fi diff --git a/nginx-alpine/Dockerfile b/nginx-alpine/Dockerfile index 8c43299..efbc51e 100644 --- a/nginx-alpine/Dockerfile +++ b/nginx-alpine/Dockerfile @@ -2,7 +2,8 @@ FROM webdevops/php-nginx:alpine MAINTAINER Belman Kraul ENV \ - WEB_DOCUMENT_ROOT="/app/public" + WEB_DOCUMENT_ROOT="/app/public" \ + APP_LOG=0 RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ sed "s/prod/dev/g" /app/.env.dist > /app/.env && \ @@ -11,8 +12,12 @@ RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ su -c '/usr/local/bin/composer require zendframework/zend-ldap --working-dir=/app' -l application && \ rm /app/.env && \ touch /app/.env && \ + touch /app/var/log/prod.log && \ + touch /app/var/log/dev.log && \ chown ${APPLICATION_UID}:${APPLICATION_GID} /app/.env COPY ./50-kimai-init.sh /opt/docker/provision/entrypoint.d/50-kimai-init.sh +COPY ./supervisor/kimai-log.sh /opt/docker/bin/service.d/kimai-log.sh +COPY ./supervisor/kimai-log.conf /opt/docker/etc/supervisor.d/kimai-log.conf -WORKDIR /app +WORKDIR /app \ No newline at end of file diff --git a/nginx-alpine/supervisor/kimai-log.conf b/nginx-alpine/supervisor/kimai-log.conf new file mode 100644 index 0000000..e3d001c --- /dev/null +++ b/nginx-alpine/supervisor/kimai-log.conf @@ -0,0 +1,14 @@ +[group:kimai-log] +programs=kimai-log +priority=20 + +[program:kimai-log] +command = /opt/docker/bin/service.d/kimai-log.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = false +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/nginx-alpine/supervisor/kimai-log.sh b/nginx-alpine/supervisor/kimai-log.sh new file mode 100644 index 0000000..61cfec1 --- /dev/null +++ b/nginx-alpine/supervisor/kimai-log.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +LOG_PATH="/app/var/log/${APP_ENV}.log" + +# only attempt logging if we have enabled logging +# and the log file exists. +if [ "${APP_LOG}" == "1" ] +then + if [ -f ${LOG_PATH} ] + then + # attempt to tail the log one line at a time. + # the supervisor job will push output to STDOUT. + echo "Now tailing ${LOG_PATH}..." + tail -f -n 1 ${LOG_PATH} + else + echo "Cannot find ${LOG_PATH}. Will now exit..." + fi +fi diff --git a/nginx-ubuntu-18.04/Dockerfile b/nginx-ubuntu-18.04/Dockerfile index a836202..6d9b486 100644 --- a/nginx-ubuntu-18.04/Dockerfile +++ b/nginx-ubuntu-18.04/Dockerfile @@ -2,7 +2,8 @@ FROM webdevops/php-nginx:ubuntu-18.04 MAINTAINER Belman Kraul ENV \ - WEB_DOCUMENT_ROOT="/app/public" + WEB_DOCUMENT_ROOT="/app/public" \ + APP_LOG=0 RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ sed "s/prod/dev/g" /app/.env.dist > /app/.env && \ @@ -11,8 +12,12 @@ RUN git clone https://github.com/kevinpapst/kimai2.git /app && \ su -c '/usr/local/bin/composer require zendframework/zend-ldap --working-dir=/app' -l application && \ rm /app/.env && \ touch /app/.env && \ + touch /app/var/log/prod.log && \ + touch /app/var/log/dev.log && \ chown ${APPLICATION_UID}:${APPLICATION_GID} /app/.env COPY ./50-kimai-init.sh /opt/docker/provision/entrypoint.d/50-kimai-init.sh +COPY ./supervisor/kimai-log.sh /opt/docker/bin/service.d/kimai-log.sh +COPY ./supervisor/kimai-log.conf /opt/docker/etc/supervisor.d/kimai-log.conf WORKDIR /app \ No newline at end of file diff --git a/nginx-ubuntu-18.04/supervisor/kimai-log.conf b/nginx-ubuntu-18.04/supervisor/kimai-log.conf new file mode 100644 index 0000000..e3d001c --- /dev/null +++ b/nginx-ubuntu-18.04/supervisor/kimai-log.conf @@ -0,0 +1,14 @@ +[group:kimai-log] +programs=kimai-log +priority=20 + +[program:kimai-log] +command = /opt/docker/bin/service.d/kimai-log.sh +process_name=%(program_name)s +startsecs = 0 +autostart = true +autorestart = false +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 diff --git a/nginx-ubuntu-18.04/supervisor/kimai-log.sh b/nginx-ubuntu-18.04/supervisor/kimai-log.sh new file mode 100644 index 0000000..61cfec1 --- /dev/null +++ b/nginx-ubuntu-18.04/supervisor/kimai-log.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +LOG_PATH="/app/var/log/${APP_ENV}.log" + +# only attempt logging if we have enabled logging +# and the log file exists. +if [ "${APP_LOG}" == "1" ] +then + if [ -f ${LOG_PATH} ] + then + # attempt to tail the log one line at a time. + # the supervisor job will push output to STDOUT. + echo "Now tailing ${LOG_PATH}..." + tail -f -n 1 ${LOG_PATH} + else + echo "Cannot find ${LOG_PATH}. Will now exit..." + fi +fi