From 8ef0df3d41142e3f72e3bf76bd81526f15322f51 Mon Sep 17 00:00:00 2001 From: Ween Jiann <16207788+lwj5@users.noreply.github.com> Date: Sat, 10 Jul 2021 02:43:43 +0800 Subject: [PATCH] Check init via tinker (#381) --- alpine/5/Dockerfile | 4 ++-- alpine/5/rootfs/usr/local/bin/docker-entrypoint | 5 ----- alpine/5/rootfs/usr/local/bin/invoiceninja-init.sh | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/alpine/5/Dockerfile b/alpine/5/Dockerfile index aa251a0..523a573 100644 --- a/alpine/5/Dockerfile +++ b/alpine/5/Dockerfile @@ -21,9 +21,9 @@ WORKDIR /var/www/app/ # Install node packages ARG BAK_STORAGE_PATH ARG BAK_PUBLIC_PATH -RUN npm install --production \ +RUN --mount=target=/var/www/app/node_modules,type=cache \ + npm install --production \ && npm run production \ - && rm -rf node_modules \ && mv /var/www/app/storage $BAK_STORAGE_PATH \ && mv /var/www/app/public $BAK_PUBLIC_PATH diff --git a/alpine/5/rootfs/usr/local/bin/docker-entrypoint b/alpine/5/rootfs/usr/local/bin/docker-entrypoint index 70eda26..babb574 100755 --- a/alpine/5/rootfs/usr/local/bin/docker-entrypoint +++ b/alpine/5/rootfs/usr/local/bin/docker-entrypoint @@ -65,11 +65,6 @@ if [ -d "$BAK_STORAGE_PATH" ]; then rm -rf "$BAK_STORAGE_PATH" fi -# prevent init scripts from running when upgrading from IN <= 5.1.62 -if [ -f /var/www/app/public/version ] && [ "$INVOICENINJA_VERSION" != "$(cat /var/www/app/public/version)" ]; then - touch /var/www/app/storage/.initialized -fi - # create public volume if [ -d "$BAK_PUBLIC_PATH" ]; then if [ ! -d /var/www/app/public ]; then diff --git a/alpine/5/rootfs/usr/local/bin/invoiceninja-init.sh b/alpine/5/rootfs/usr/local/bin/invoiceninja-init.sh index cb5e7f5..92d4cfc 100755 --- a/alpine/5/rootfs/usr/local/bin/invoiceninja-init.sh +++ b/alpine/5/rootfs/usr/local/bin/invoiceninja-init.sh @@ -38,7 +38,7 @@ fi php artisan migrate --force # If first IN run, it needs to be initialized -if [ ! -f /var/www/app/storage/.initialized ]; then +IN_INIT=$(php artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();') +if [ "$IN_INIT" == "1" ]; then docker_process_init_files /docker-entrypoint-init.d/* - touch /var/www/app/storage/.initialized fi