Created
October 13, 2020 12:50
-
-
Save frinux/027cf804b1ee8e2b993019c33b2a23e4 to your computer and use it in GitHub Desktop.
Laravel docker entrypoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Script used as command for Docker | |
# thanks https://laravel-news.com/laravel-scheduler-queue-docker | |
set -e | |
role=${CONTAINER_ROLE:-app} | |
if [[ "$role" = "app" ]]; then | |
echo "Launch Apache2" | |
exec apache2-foreground | |
elif [[ "$role" = "migrate" ]]; then | |
echo "Execute database migration scripts" | |
php /var/www/html/artisan migrate --force | |
elif [[ "$role" = "queue_worker" ]]; then | |
echo "Running the queue..." | |
php /var/www/html/artisan queue:work --verbose --tries=3 --timeout=90 | |
elif [[ "$role" = "horizon" ]]; then | |
echo "Running the queue through horizon..." | |
php /var/www/html/artisan horizon | |
elif [[ "$role" = "phpunit_unit" ]]; then | |
echo "Running PHPUnit: Unit tests" | |
cd /var/www/html/ && ./vendor/phpunit/phpunit/phpunit --testsuite "Unit Tests" | |
elif [[ "$role" = "phpunit_features" ]]; then | |
echo "Running PHPUnit: Features" | |
cd /var/www/html/ && ./vendor/phpunit/phpunit/phpunit --testsuite "Feature Tests" | |
elif [[ "$role" = "scheduler" ]]; then | |
while [[ true ]] | |
do | |
php /var/www/html/artisan schedule:run --verbose --no-interaction & | |
sleep 60 | |
done | |
else | |
echo "Could not match the container role \"$role\"" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment