#!/usr/bin/env sh set -e role=${CONTAINER_ROLE:-app} if [ "$APP_ENV" = "production" ]; then php artisan config:cache php artisan event:cache php artisan route:cache php artisan view:cache php artisan storage:link fi if [ "$role" = "app" ]; then export PHP_FPM_MEMORY_LIMIT="${PHP_FPM_MEMORY_LIMIT:-256m}" export PHP_FPM_UPLOAD_MAX_FILESIZE="${PHP_FPM_UPLOAD_MAX_FILESIZE:-20m}" export PHP_FPM_POST_MAX_SIZE="${PHP_FPM_POST_MAX_SIZE:-20m}" export PHP_FPM_PM_MAX_CHILDREN="${PHP_FPM_PM_MAX_CHILDREN:-10}" export PHP_FPM_PM_START_SERVERS="${PHP_FPM_PM_START_SERVERS:-5}" export PHP_FPM_PM_MIN_SPARE_SERVERS="${PHP_FPM_PM_MIN_SPARE_SERVERS:-2}" export PHP_FPM_PM_MAX_SPARE_SERVERS="${PHP_FPM_PM_MAX_SPARE_SERVERS:-5}" export PHP_FPM_PM_MAX_REQUESTS="${PHP_FPM_PM_MAX_REQUESTS:-500}" if [ "$APP_ENV" = "production" ]; then export PHP_FPM_DISPLAY_ERRORS="${PHP_FPM_DISPLAY_ERRORS:-0}" export PHP_FPM_OPCACHE_ENABLE="${PHP_FPM_OPCACHE_ENABLE:-1}" export PHP_FPM_OPCACHE_VALIDATE_TIMESTAMPS="${PHP_FPM_OPCACHE_VALIDATE_TIMESTAMPS:-0}" php artisan migrate --force else export PHP_FPM_DISPLAY_ERRORS="${PHP_FPM_DISPLAY_ERRORS:-1}" export PHP_FPM_OPCACHE_ENABLE="${PHP_FPM_OPCACHE_ENABLE:-0}" export PHP_FPM_OPCACHE_VALIDATE_TIMESTAMPS="${PHP_FPM_OPCACHE_VALIDATE_TIMESTAMPS:-1}" fi if [ ! -w /var/www/html/storage ]; then echo "ERROR: /var/www/html/storage must be writable." echo "Fix permissions on host/volume for the www-data user." exit 1 fi exec php-fpm elif [ "$role" = "queue" ]; then echo "Running the queue..." while [ true ] do php /var/www/html/artisan queue:work --verbose --sleep=5 --tries=100 --backoff=10 --max-time=3600 --queue=high,normal,low,default done 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