Merge pull request #805 from benbrummer/debian

Optimize artisan commands and add healthcheck as condition for app
This commit is contained in:
David Bomba
2025-09-29 08:10:00 +10:00
committed by GitHub
5 changed files with 12 additions and 11 deletions

2
debian/Dockerfile vendored
View File

@@ -82,7 +82,7 @@ COPY --from=prepare-app /tmp/public /tmp/public
COPY --chmod=0755 scripts/init.sh /usr/local/bin/init.sh
# Health check
HEALTHCHECK --start-period=10s \
HEALTHCHECK --start-period=100s \
CMD REMOTE_ADDR=127.0.0.1 REQUEST_URI=/health REQUEST_METHOD=GET SCRIPT_FILENAME=/var/www/html/public/index.php cgi-fcgi -bind -connect 127.0.0.1:9000 | grep '{"status":"ok","message":"API is healthy"}'
ENTRYPOINT ["/usr/local/bin/init.sh"]

View File

@@ -40,7 +40,8 @@ services:
networks:
- app-network
depends_on:
- app
app:
condition: service_healthy
logging: *default-logging
mysql:

View File

@@ -41,24 +41,26 @@ if [ "$*" = 'supervisord -c /etc/supervisor/supervisord.conf' ]; then
# Clear and cache config in production
if [ "$APP_ENV" = "production" ]; then
runuser -u www-data -- php artisan optimize
runuser -u www-data -- php artisan package:discover
runuser -u www-data -- php artisan migrate --force
runuser -u www-data -- php artisan migrate --force
runuser -u www-data -- php artisan cache:clear # Clear after the migration
runuser -u www-data -- php artisan ninja:design-update
runuser -u www-data -- php artisan optimize
# If first IN run, it needs to be initialized
if [ "$(php -d opcache.preload='' artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')" = "1" ]; then
if [ "$(runuser -u www-data -- php artisan tinker --execute='echo Schema::hasTable("accounts") && !App\Models\Account::all()->first();')" = "1" ]; then
echo "Running initialization..."
php artisan db:seed --force
runuser -u www-data -- php artisan db:seed --force
if [ -n "${IN_USER_EMAIL}" ] && [ -n "${IN_PASSWORD}" ]; then
php artisan ninja:create-account --email "${IN_USER_EMAIL}" --password "${IN_PASSWORD}"
runuser -u www-data -- php 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
fi
echo "Production setup completed"
fi

View File

@@ -1 +0,0 @@

View File

@@ -1 +0,0 @@