Context
There are too many things to consider when deploying a PHP Docker setup in Kubernetes, many of them related to good practices and others due to how PHP is designed, the intent of this issue is to list all of them and match whether we have both solved the issue and documented it.
THE list
- Starting with Docker best practices
- Nginx and PHP-FPM, after handling signals correctly, let's understand the relationship of those components.
# Considering you have a mount between the nginx and php-fpm containers on `/var/run`
lifecycle:
preStop:
exec:
command: ["/bin/sh","-c","while test -e /var/run/nginx.pid; do sleep 1; done"]
Context
There are too many things to consider when deploying a PHP Docker setup in Kubernetes, many of them related to good practices and others due to how PHP is designed, the intent of this issue is to list all of them and match whether we have both solved the issue and documented it.
THE list
pcntlby default.Which means SIGTERM and SIGINT will be ignored and the process will die non gracefully, also the application must know how to deal with the signal
php-docker-template/Dockerfile-fpm
Lines 20 to 21 in 7fd241a
preStopwhich checks if the Nginx is dead before PHP-FPM:WARNING: [pool www] child 12 said into stdout :.7.3 has a fix for that, but what to do with 7.2? https://www.php.net/manual/en/migration73.new-features.php#migration73.new-features.fpm
php-docker-template/Makefile
Lines 67 to 68 in 436042e