Run Laravel schedule in docker image using supervisord #6606
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the docker image so that
artisan schedule:run
is executed every minute by a supervisord command.Since it seems that Laravel Task Scheduling is preferred over creating various crontab entries, this should cover all of snipe-it's needs. If everyone can agree to this, then this effectively fixes issue #6344. If not, then I'll have to modify this to use
cron
(see below).Cron
History:
cron
package but didn't arrange to actually runcron
.cron
to the list of installed packages.Using
cron
to run the Laravel schedule is problematic becausecron
doesn't preserve the outside environment variables. This is especially unfortunate for Docker containers where the Docker-provided environment is the key source of configuration.While there is a method to access the docker-set environment variables from the cron job, the whole thing seemed overkill.
Supervisor
Rather than using tini, Supervisor is added to the docker image and is used to start apache2 and run the Laravel schedule in a simple sleep loop.
I also considered forego, which was preferred over supervisor by nginx-proxy/nginx-proxy#165. Unfortunately, it didn't work well; sending
SIGINT
to forego failed to properly shut down apache. Also, this wouldn't have provided as clean of a solution for the Laravel schedule.Testing
I temporarily made the following change in my running Docker container.
After a few minutes:
https://localhost:8888/admin/backups
and saw that several backups had been created./tmp/backup.log
:/var/lib/snipeit/dumps/
were owned bydocker:staff