#!/bin/sh # Exit on any error set -e # Wait for database to be ready until php artisan tinker --execute="DB::connection()->getPdo();" > /dev/null 2>&1; do echo "Waiting for database connection..." sleep 2 done # Run migrations on first start (web container only) if [ "$1" = "web" ]; then php artisan migrate --force fi # Execute the command based on the argument case "$1" in "web") echo "Starting web server..." exec php artisan serve --host=0.0.0.0 --port=8000 ;; "queue") echo "Starting queue worker..." exec php artisan queue:work --tries=3 ;; *) echo "Usage: $0 {web|queue}" exit 1 ;; esac