Merge pull request #686 from benbrummer/frankenphp

healthcheck for scheduler and worker
This commit is contained in:
David Bomba
2025-01-11 16:40:22 +11:00
committed by GitHub
3 changed files with 38 additions and 5 deletions

6
debian/Dockerfile vendored
View File

@@ -6,8 +6,6 @@ RUN curl -s "https://api.github.com/repos/invoiceninja/invoiceninja/releases/lat
xargs curl -sL | \
tar -xz \
&& ln -s ./resources/views/react/index.blade.php ./public/index.html \
# Set permissions: directories 755, files 644
&& chmod -R a=r,u+w,a+X . \
# Symlink
&& php artisan storage:link \
# Octane
@@ -69,7 +67,9 @@ RUN install-php-extensions \
${php_extra}
# Configure PHP
RUN mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini"
RUN ln -s "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini"
COPY php/php.ini /usr/local/etc/php/conf.d/invoiceninja.ini
# Create directory for artisan tinker (init.sh)
RUN mkdir /config/psysh \

View File

@@ -9,7 +9,6 @@ x-logging: &default-logging
x-app-volumes: &volumes
volumes:
- ./.env:/app/.env
- ./php/php.ini:/usr/local/etc/php/conf.d/zzz-php.ini:ro
- app_cache:/var/www/html/bootstrap/cache
- app_storage:/app/storage
- caddy_data:/data
@@ -26,7 +25,7 @@ services:
ports:
- "80:80" # HTTP
# - "443:443" # HTTPS
# - "443:443/udp" # HTTP/3, causes an error for pdf preview H3_GENERAL_PROTOCOL_ERROR
# - "443:443/udp" # HTTP/3, Works for chromium based browser, but causes H3_GENERAL_PROTOCOL_ERROR for pdf previews in Firefox
env_file:
- ./.env
environment:
@@ -59,6 +58,9 @@ services:
environment:
LARAVEL_ROLE: worker
<<: *volumes
healthcheck:
test: ["CMD", "pgrep", "-f", "queue:work"]
start_period: 10s
depends_on:
app:
condition: service_healthy
@@ -74,6 +76,9 @@ services:
environment:
LARAVEL_ROLE: scheduler
<<: *volumes
healthcheck:
test: ["CMD", "pgrep", "-f", "schedule:work"]
start_period: 10s
depends_on:
app:
condition: service_healthy

View File

@@ -6,6 +6,34 @@ role=${LARAVEL_ROLE:-app}
# Check for default CMD, flag(s) or empty CMD
if [ "$*" = 'frankenphp php-cli artisan octane:frankenphp' ] || [ "${1#-}" != "$1" ] || [ "$#" -eq "0" ]; then
if [ "--help" = "$1" ]; then
echo [CMD]
echo "This image will execute specific CMDs based on the environment variable LARAVEL_ROLE"
echo
echo "LARAVEL_ROLE=app: frankenphp php-cli artisan octane:frankenphp (default)"
echo "LARAVEL_ROLE=worker: frankenphp php-cli artisan queue:work"
echo "LARAVEL_ROLE=scheduler: frankenphp php-cli artisan schedule:work"
echo
echo [FLAGS]
echo To the CMD defined by LARAVEL_ROLE can be extended with flags for artisan commands
echo
echo Available flags can be displaced:
echo docker run --rm invoiceninja/invoiceninja-debian frankenphp php-cli artisan help octane:frankenphp
echo docker run --rm invoiceninja/invoiceninja-debian frankenphp php-cli artisan queue:work
echo docker run --rm invoiceninja/invoiceninja-debian frankenphp php-cli artisan schedule:work
echo
echo Example:
echo docker run -e LARAVEL_ROLE=worker invoiceninja/invoiceninja-debian --verbose --sleep=3 --tries=3 --max-time=3600
echo
echo [Deployment]
echo Docker compose is recommended
echo
echo Example:
echo https://github.com/invoiceninja/dockerfiles/blob/octane/debian/docker-compose.yml
echo
exit 0
fi
# Run app
if [ "${role}" = "app" ]; then
cmd="frankenphp php-cli artisan octane:frankenphp"