mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2025-12-31 19:47:25 +01:00
* Added checks to docker-entrypoint * Add init scripts feature * Added backward compatibility * Added auto user creation * Updated README.md and env * Use dbCheck for checking DB connection
46 lines
1.2 KiB
Bash
Executable File
46 lines
1.2 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 "$0: running $f"
|
|
"$f"
|
|
else
|
|
in_log "$0: sourcing $f"
|
|
. "$f"
|
|
fi
|
|
;;
|
|
*) in_log "$0: ignoring $f" ;;
|
|
esac
|
|
echo
|
|
done
|
|
}
|
|
|
|
php artisan config:cache
|
|
php artisan optimize
|
|
|
|
# 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
|
|
echo "Error connecting to DB"
|
|
php artisan migrate:status # Print verbose error
|
|
exit 1
|
|
fi
|
|
|
|
php artisan migrate --force
|
|
|
|
# If first IN run, it needs to be initialized
|
|
if [ ! -f /var/www/app/storage/.initialized ]; then
|
|
docker_process_init_files /docker-entrypoint-init.d/*
|
|
touch /var/www/app/storage/.initialized
|
|
fi
|