Skip to content

Commit

Permalink
add scheduler to prod dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilReinking committed Aug 31, 2023
1 parent 5763a3f commit 5e3e66a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ COPY --chown=nobody . .

RUN composer install --optimize-autoloader --no-interaction --no-progress

# Remove Composer Cache & Script since we do not need it any more
USER root

# Remove Composer Cache & Script since we do not need it any more
RUN rm -rf /root/.composer /usr/bin/composer

# Copy Supervisor Config for Scheduler
COPY scheduler.conf /tmp/scheduler.conf
RUN cat /tmp/scheduler.conf >> /etc/supervisor/conf.d/supervisord.conf && rm -f /tmp/scheduler.conf

USER nobody

# ---
Expand Down
1 change: 1 addition & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command('cache:prune-stale-tags')->hourly();
$schedule->command('input:auto-delete-submissions')->twiceDaily();
}

/**
Expand Down
10 changes: 10 additions & 0 deletions scheduler.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[program:artisan-schedule]
; Run the Laravel Artisan scheduler every minute
command=/bin/sh -c "while true; do (php /var/www/html/artisan schedule:run --verbose --no-interaction &); sleep 60; done"
autostart=true
autorestart=true
numprocs=1
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

0 comments on commit 5e3e66a

Please sign in to comment.