Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Multiprocess PHP Containers with S6 Overlay - ConFoo 2023

Multiprocess PHP Containers with S6 Overlay - ConFoo 2023

In the pre-container era, the most common way of running PHP applications was with Nginx + PHP-FPM, with containers this is harder as you need two processes: Nginx and PHP-FPM.

S6 Overlay can help to manage multi-process applications in a container - it takes the burden of security aspects, signal handling, configuration and log management off your shoulders & make your code more readable!

URL: https://confoo.ca/en/2023
---
Info about S3 Overlay: https://github.com/just-containers/s6-overlay

Johan Janssens

February 24, 2023
Tweet

More Decks by Johan Janssens

Other Decks in Programming

Transcript

  1. 1 In the pre-container era, the most common way of

    running PHP applications was with Nginx + PHP-FPM, with containers this is harder as you need two processes: PHP requires a web server process (nginx, apache, caddy, …) and a PHP-FPM process in order to run your application The Problem
  2. 2 Official PHP Docker Images The official PHP Docker images

    are single process containers offered in 2 flavours: 
 
 1. PHP + PHPFPM (*) 
 2. PHP + Apache (running mod_php) 
 
 (*) In order to use this image variant, some kind of reverse proxy (such as NGINX, Apache, or other tool which speaks the FastCGI protocol) will be required. 
 
 More info: https://github.com/docker-library/php
  3. 3 S6 Overlay can help to manage multi-process applications in

    a container - it takes the burden of security aspects, signal handling, configuration and log management off your shoulders & make your code more readable! 
 
 Its based on s6 is a small suite of programs for UNIX, designed to allow process supervision (a.k.a service supervision), in the line of daemontools and runit, as well as various operations on processes and daemons 
 
 More info: • https://skarnet.org/software/s6/ • https://github.com/just-containers/s6-overlay S6 Overlay
  4. 4 S6 Overlay Philosophy There's nothing inherently bad about running

    multiple processes in a container. The more abstract "one thing per container" is our policy - a container should do one thing, such as "run a chat service" or "run gitlab." This may involve multiple processes, which is fine. S6’s interpretation of "The Docker Way" is thus: • Containers should do one thing • Containers should stop when that thing stops If "the thing" fails, then the container should fail, too. We do this by determining which processes can restart, and which should bring down the container.
  5. https:// fl y.io/ (*) Only works with S6 Overlay 2.x,

    requires FROM serversideup/php:8.1-fpm-nginxv1.5.0