mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2025-12-31 19:47:25 +01:00
updates for debian
This commit is contained in:
54
debian/scripts/init.sh
vendored
54
debian/scripts/init.sh
vendored
@@ -1,6 +1,34 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
|
||||
in_log() {
|
||||
local type="$1"; shift
|
||||
printf '%s [%s] [Entrypoint]: %s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$type" "$*"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
# Create directories if they don't exist
|
||||
mkdir -p \
|
||||
/var/www/html/storage/app/public \
|
||||
@@ -19,9 +47,27 @@ chmod -R 775 \
|
||||
# Clear and cache config in production
|
||||
if [ "$APP_ENV" = "production" ]; then
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
php artisan optimize
|
||||
php artisan package:discover
|
||||
php artisan migrate --force
|
||||
|
||||
echo "Checking initialization status..."
|
||||
|
||||
# If first IN run, it needs to be initialized
|
||||
echo "Checking initialization status..."
|
||||
IN_INIT=$(php artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')
|
||||
echo "IN_INIT value: $IN_INIT"
|
||||
|
||||
if [ "$IN_INIT" = "1" ]; then
|
||||
echo "Running initialization scripts..."
|
||||
docker_process_init_files /docker-entrypoint-init.d/*
|
||||
fi
|
||||
|
||||
echo "Production setup completed"
|
||||
echo "IN_INIT value: $IN_INIT"
|
||||
|
||||
fi
|
||||
|
||||
# Start supervisord
|
||||
exec "$@"
|
||||
echo "Starting supervisord..."
|
||||
# Start supervisord in the foreground
|
||||
exec /usr/bin/supervisord -n -c /etc/supervisor/conf.d/supervisord.conf
|
||||
Reference in New Issue
Block a user