From c0350de41866ac9e4cae4b3da4790848492c708e Mon Sep 17 00:00:00 2001 From: Lee Ween Jiann Date: Tue, 23 Mar 2021 19:47:11 +0800 Subject: [PATCH 1/4] Modified to fit k8s --- alpine/Dockerfile_v5 | 14 +++++++------- config/php/php.ini | 2 +- config/supervisor/supervisord.conf | 6 ++---- entrypoint.sh | 8 +++++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/alpine/Dockerfile_v5 b/alpine/Dockerfile_v5 index b513a4b..9c9f704 100644 --- a/alpine/Dockerfile_v5 +++ b/alpine/Dockerfile_v5 @@ -44,9 +44,8 @@ LABEL maintainer="David Bomba " WORKDIR /var/www/app COPY --from=frontend /var/www/app /var/www/app -COPY entrypoint.sh /usr/local/bin/docker-entrypoint -RUN chmod +x /usr/local/bin/docker-entrypoint \ - && mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini + +RUN mv /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini # Install PHP extensions # https://hub.docker.com/r/mlocati/php-extension-installer/tags @@ -72,6 +71,7 @@ RUN set -eux; \ chromium \ ttf-freefont +COPY entrypoint.sh /usr/local/bin/docker-entrypoint COPY ./config/php/php.ini /usr/local/etc/php/conf.d/in-php.ini COPY ./config/supervisor/supervisord.conf / @@ -87,10 +87,10 @@ RUN addgroup --gid=$UID -S "$INVOICENINJA_USER" \ --ingroup "$INVOICENINJA_USER" \ --no-create-home \ "$INVOICENINJA_USER" \ - && addgroup "$INVOICENINJA_USER" www-data \ - && mkdir /var/log/supervisord /var/run/supervisord \ - && chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /var/www/app \ - && chown $INVOICENINJA_USER:www-data /var/log/supervisord /var/run/supervisord + && chmod +x /usr/local/bin/docker-entrypoint \ + && mkdir /app /var/log/supervisord \ + && chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /app \ + && chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /var/www/app USER $UID diff --git a/config/php/php.ini b/config/php/php.ini index e614f65..1ecaf93 100644 --- a/config/php/php.ini +++ b/config/php/php.ini @@ -14,4 +14,4 @@ realpath_cache_ttl = 600 ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize -upload_max_filesize = 8M \ No newline at end of file +upload_max_filesize = 8M diff --git a/config/supervisor/supervisord.conf b/config/supervisor/supervisord.conf index 80c968b..efeb566 100644 --- a/config/supervisor/supervisord.conf +++ b/config/supervisor/supervisord.conf @@ -1,14 +1,12 @@ [supervisord] nodaemon=true user=invoiceninja -pidfile=/var/run/supervisord/supervisord.pid +pidfile=/tmp/supervisord.pid logfile=/dev/null ; nodaemon will cause logs to go to stdout logfile_maxbytes=0 -loglevel=error +loglevel=info [program:php-fpm] -autostart=true -autorestart=true redirect_stderr=true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 diff --git a/entrypoint.sh b/entrypoint.sh index 9967f20..d32b35d 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -82,9 +82,6 @@ elif [ -d "$BAK_PUBLIC_PATH/logo" ]; then fi rm -rf "$BAK_PUBLIC_PATH" -# Set permission for web server to create/update files -chown -R "$INVOICENINJA_USER":www-data /var/www/app/storage /var/www/app/public /var/www/app/bootstrap - # Initialize values that might be stored in a file file_env 'APP_KEY' file_env 'API_SECRET' @@ -104,6 +101,11 @@ file_env 'S3_SECRET' # Run Laravel stuff php artisan config:cache php artisan optimize + +while ! mysqladmin ping -h "$DB_HOST1" -P $DB_PORT1 --silent; do + echo "Waiting for DB ($DB_HOST1:$DB_PORT1)" + sleep 1 +done php artisan migrate --force exec docker-php-entrypoint "$@" From f16815e960a4d68847c4d02ef46f94030527214a Mon Sep 17 00:00:00 2001 From: Lee Ween Jiann Date: Tue, 23 Mar 2021 23:18:29 +0800 Subject: [PATCH 2/4] Updated supervisor files --- alpine/Dockerfile_v5 | 5 ++--- config/shutdown.sh | 8 -------- config/supervisor/shutdown.sh | 8 ++++++++ config/supervisor/supervisord.conf | 2 -- 4 files changed, 10 insertions(+), 13 deletions(-) delete mode 100644 config/shutdown.sh create mode 100644 config/supervisor/shutdown.sh diff --git a/alpine/Dockerfile_v5 b/alpine/Dockerfile_v5 index 9c9f704..1ed30a2 100644 --- a/alpine/Dockerfile_v5 +++ b/alpine/Dockerfile_v5 @@ -73,7 +73,7 @@ RUN set -eux; \ COPY entrypoint.sh /usr/local/bin/docker-entrypoint COPY ./config/php/php.ini /usr/local/etc/php/conf.d/in-php.ini -COPY ./config/supervisor/supervisord.conf / +COPY ./config/supervisor/* / ## Separate user ARG UID=1500 @@ -88,8 +88,7 @@ RUN addgroup --gid=$UID -S "$INVOICENINJA_USER" \ --no-create-home \ "$INVOICENINJA_USER" \ && chmod +x /usr/local/bin/docker-entrypoint \ - && mkdir /app /var/log/supervisord \ - && chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /app \ + && chmod +x /shutdown.sh \ && chown -R "$INVOICENINJA_USER":"$INVOICENINJA_USER" /var/www/app USER $UID diff --git a/config/shutdown.sh b/config/shutdown.sh deleted file mode 100644 index 3edbdf8..0000000 --- a/config/shutdown.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -printf "READY\n"; - -while read line; do - echo "Processing Event: $line" >&2; - kill -SIGQUIT $PPID -done < /dev/stdin \ No newline at end of file diff --git a/config/supervisor/shutdown.sh b/config/supervisor/shutdown.sh new file mode 100644 index 0000000..c6171ee --- /dev/null +++ b/config/supervisor/shutdown.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +printf "READY\n" + +while read line; do + echo "Processing Event: $line" >&2 + kill -SIGQUIT $PPID +done Date: Wed, 24 Mar 2021 08:14:30 +0800 Subject: [PATCH 3/4] Updated entrypoint to chown only in <4 --- config/supervisor/supervisord.conf | 1 - entrypoint.sh | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/config/supervisor/supervisord.conf b/config/supervisor/supervisord.conf index 1da1c06..bb42e7c 100644 --- a/config/supervisor/supervisord.conf +++ b/config/supervisor/supervisord.conf @@ -40,4 +40,3 @@ stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 - diff --git a/entrypoint.sh b/entrypoint.sh index d32b35d..75ce433 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -82,6 +82,11 @@ elif [ -d "$BAK_PUBLIC_PATH/logo" ]; then fi rm -rf "$BAK_PUBLIC_PATH" +# Set permission for web server to create/update files (only Date: Wed, 24 Mar 2021 08:40:35 +0800 Subject: [PATCH 4/4] Added DB_PORT1 to env --- env | 1 + 1 file changed, 1 insertion(+) diff --git a/env b/env index 0b8baaf..713d261 100644 --- a/env +++ b/env @@ -3,6 +3,7 @@ APP_KEY= APP_DEBUG=true MULTI_DB_ENABLED=false DB_HOST1=db +DB_PORT1=3306 DB_USERNAME1=ninja DB_PASSWORD1=ninja DB_DATABASE1=ninja