mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2025-12-31 19:47:25 +01:00
46 lines
1.3 KiB
Bash
Executable File
46 lines
1.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# usage: docker_process_init_files [file [file [...]]]
|
|
# ie: docker_process_init_files /always-initdb.d/*
|
|
# process initializer files, based on file extensions
|
|
docker_process_init_files() {
|
|
echo
|
|
local f
|
|
for f; do
|
|
case "$f" in
|
|
*.sh)
|
|
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
|
|
# https://github.com/docker-library/postgres/pull/452
|
|
if [ -x "$f" ]; then
|
|
in_log INFO "$0: running $f"
|
|
"$f"
|
|
else
|
|
in_log INFO "$0: sourcing $f"
|
|
. "$f"
|
|
fi
|
|
;;
|
|
*) in_log INFO "$0: ignoring $f" ;;
|
|
esac
|
|
echo
|
|
done
|
|
}
|
|
|
|
php artisan config:cache
|
|
php artisan optimize
|
|
php artisan package:discover
|
|
|
|
# Check if DB works, if not crash the app.
|
|
DB_READY=$(php artisan tinker --execute='echo app()->call("App\Utils\SystemHealth@dbCheck")["success"];')
|
|
if [ "$DB_READY" != "1" ]; then
|
|
php artisan migrate:status # Print verbose error
|
|
in_error "Error connecting to DB"
|
|
fi
|
|
|
|
php artisan migrate --force
|
|
|
|
# If first IN run, it needs to be initialized
|
|
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/*
|
|
fi
|