mirror of
https://github.com/invoiceninja/dockerfiles.git
synced 2026-01-18 04:14:04 +01:00
octane and multistage
This commit is contained in:
35
debian/scripts/init.sh
vendored
35
debian/scripts/init.sh
vendored
@@ -1,42 +1,57 @@
|
||||
#!/bin/sh -eu
|
||||
|
||||
app_dir=${APP_DIR:-/app}
|
||||
# Fallback to app
|
||||
role=${LARAVEL_ROLE:-app}
|
||||
|
||||
if [ "$*" = 'frankenphp run --config /etc/caddy/Caddyfile --adapter caddyfile' ]; then
|
||||
# Check for default CMD, flag(s) or empty CMD
|
||||
if [ "$*" = 'frankenphp php-cli artisan octane:frankenphp' ] || [ "${1#-}" != "$1" ] || [ "$#" -eq "0" ]; then
|
||||
|
||||
# Run app
|
||||
if [ "${role}" = "app" ]; then
|
||||
cmd="frankenphp php-cli artisan octane:frankenphp"
|
||||
|
||||
if [ "$APP_ENV" = "production" ]; then
|
||||
frankenphp php-cli "${app_dir}"/artisan optimize
|
||||
frankenphp php-cli artisan optimize
|
||||
fi
|
||||
|
||||
frankenphp php-cli "${app_dir}"/artisan package:discover
|
||||
frankenphp php-cli artisan package:discover
|
||||
|
||||
frankenphp php-cli "${app_dir}"/artisan migrate --force
|
||||
# Run migrations (if any)
|
||||
frankenphp php-cli 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
|
||||
if [ "$(frankenphp php-cli 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
|
||||
frankenphp php-cli 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}"
|
||||
frankenphp php-cli 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"
|
||||
# Run worker
|
||||
elif [ "${role}" = "worker" ]; then
|
||||
exec frankenphp php-cli "${app_dir}"/artisan queue:work -v --sleep=3 --tries=3 --max-time=3600
|
||||
cmd="frankenphp php-cli artisan queue:work"
|
||||
# Run scheduler
|
||||
elif [ "${role}" = "scheduler" ]; then
|
||||
exec frankenphp php-cli "${app_dir}"/artisan schedule:work -v
|
||||
cmd="frankenphp php-cli artisan schedule:work"
|
||||
# Invalid role
|
||||
else
|
||||
echo "Invalid role: ${role}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Append flag(s) to role cmd
|
||||
if [ "${1#-}" != "$1" ]; then
|
||||
set -- ${cmd} "$@"
|
||||
else
|
||||
set -- ${cmd}
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
||||
Reference in New Issue
Block a user