mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2026-01-15 19:04:03 +01:00
43 lines
1.5 KiB
Bash
Executable File
43 lines
1.5 KiB
Bash
Executable File
#!/bin/sh -eu
|
|
|
|
app_dir=${APP_DIR:-/app}
|
|
role=${LARAVEL_ROLE:-app}
|
|
|
|
if [ "$*" = 'frankenphp run --config /etc/caddy/Caddyfile --adapter caddyfile' ]; then
|
|
|
|
if [ "${role}" = "app" ]; then
|
|
if [ "$APP_ENV" = "production" ]; then
|
|
frankenphp php-cli "${app_dir}"/artisan optimize
|
|
fi
|
|
|
|
frankenphp php-cli "${app_dir}"/artisan package:discover
|
|
|
|
frankenphp php-cli "${app_dir}"/artisan migrate --force
|
|
|
|
# If first IN run, it needs to be initialized
|
|
if [ "$(frankenphp php-cli "${app_dir}"/artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')" = "1" ]; then
|
|
echo "Running initialization..."
|
|
|
|
frankenphp php-cli "${app_dir}"/artisan db:seed --force
|
|
|
|
if [ -n "${IN_USER_EMAIL}" ] && [ -n "${IN_PASSWORD}" ]; then
|
|
frankenphp php-cli "${app_dir}"/artisan ninja:create-account --email "${IN_USER_EMAIL}" --password "${IN_PASSWORD}"
|
|
else
|
|
echo "Initialization failed - Set IN_USER_EMAIL and IN_PASSWORD in .env"
|
|
exit 1
|
|
fi
|
|
fi
|
|
echo "Production setup completed"
|
|
elif [ "${role}" = "worker" ]; then
|
|
exec frankenphp php-cli "${app_dir}"/artisan queue:work -v --sleep=3 --tries=3 --max-time=3600
|
|
elif [ "${role}" = "scheduler" ]; then
|
|
exec frankenphp php-cli "${app_dir}"/artisan schedule:work -v
|
|
else
|
|
echo "Invalid role: ${role}"
|
|
exit 1
|
|
fi
|
|
|
|
fi
|
|
|
|
exec "$@"
|