diff --git a/README.md b/README.md index 8ec68d1..749c0d2 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,14 @@ # General purpose PHP images for Docker -> **The fpm variant has a built-in Apache** (`PHP_FPM_WEB_SERVER=apache`): the same features as the `apache` variant, -> with 63% more traffic served with HTTPS and up to 29% more during a traffic peak -> ([benchmark](benchmarks/capacity/README.md)). It is the recommended variant to serve a web application: see -> [Serving with the fpm variant](docs/fpm.md) and the [tuning simulator](https://thecodingmachine.github.io/docker-images-php/tuning/). +> **What's new** +> +> - **PHP 8.6**: images for PHP 8.6, with all the extensions of the other versions except swoole. +> - **Debugging, profiling, coverage**: an [interactive guide](https://thecodingmachine.github.io/docker-images-php/debugging/) picks the tools for your needs +> (Xdebug, PCOV, Excimer, XHProf, SPX…) and gives the setup of your IDE and your AI agent. `PHP_PROFILER` profiles +> requests and commands on a trigger. +> - **Documentation site**: [thecodingmachine.github.io/docker-images-php](https://thecodingmachine.github.io/docker-images-php/), in English and in French, +> with the tuning simulator and the reverse proxy guide. This repository contains a set of developer-friendly, general purpose PHP images for Docker. @@ -25,113 +29,21 @@ See the [documentation](#documentation) for all the features. ## Images +The main images, for PHP 8.6: +| Use | Image | +|--------------------------------------------------------------|----------------------------------------------------------------| +| Web application: Apache + `mod_php` | `thecodingmachine/php:8.6-v5-apache` | +| Web application: PHP-FPM (see [the fpm variant](docs/fpm.md)) | `thecodingmachine/php:8.6-v5-fpm` | +| CLI: scripts, workers, CI | `thecodingmachine/php:8.6-v5-cli` | +| With NodeJS 24, to build your assets | `thecodingmachine/php:8.6-v5-apache-node24` | +| Production (*slim*): only the extensions listed at build time | `thecodingmachine/php:8.6-v5-slim-apache` | - -| Name | PHP version | type |variant | NodeJS version | Size -|-------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------|--------|-----------------|------ -| [thecodingmachine/php:8.6-v5-apache](Dockerfile.apache) | `8.6.x` | fat | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-apache) -| [thecodingmachine/php:8.6-v5-apache-node22](Dockerfile.apache.node) | `8.6.x` | fat | apache | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-apache-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-apache-node22) -| [thecodingmachine/php:8.6-v5-apache-node24](Dockerfile.apache.node) | `8.6.x` | fat | apache | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-apache-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-apache-node24) -| [thecodingmachine/php:8.6-v5-apache-node26](Dockerfile.apache.node) | `8.6.x` | fat | apache | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-apache-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-apache-node26) -| [thecodingmachine/php:8.6-v5-fpm](Dockerfile.fpm) | `8.6.x` | fat | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-fpm) -| [thecodingmachine/php:8.6-v5-fpm-node22](Dockerfile.fpm.node) | `8.6.x` | fat | fpm | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-fpm-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-fpm-node22) -| [thecodingmachine/php:8.6-v5-fpm-node24](Dockerfile.fpm.node) | `8.6.x` | fat | fpm | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-fpm-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-fpm-node24) -| [thecodingmachine/php:8.6-v5-fpm-node26](Dockerfile.fpm.node) | `8.6.x` | fat | fpm | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-fpm-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-fpm-node26) -| [thecodingmachine/php:8.6-v5-cli](Dockerfile.cli) | `8.6.x` | fat | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-cli) -| [thecodingmachine/php:8.6-v5-cli-node22](Dockerfile.cli.node) | `8.6.x` | fat | cli | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-cli-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-cli-node22) -| [thecodingmachine/php:8.6-v5-cli-node24](Dockerfile.cli.node) | `8.6.x` | fat | cli | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-cli-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-cli-node24) -| [thecodingmachine/php:8.6-v5-cli-node26](Dockerfile.cli.node) | `8.6.x` | fat | cli | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-cli-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-cli-node26) -| [thecodingmachine/php:8.6-v5-slim-apache](Dockerfile.slim.apache) | `8.6.x` | slim | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-slim-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-slim-apache) -| [thecodingmachine/php:8.6-v5-slim-fpm](Dockerfile.slim.fpm) | `8.6.x` | slim | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-slim-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-slim-fpm) -| [thecodingmachine/php:8.6-v5-slim-cli](Dockerfile.slim.cli) | `8.6.x` | slim | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.6-v5-slim-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.6-v5-slim-cli) -| [thecodingmachine/php:8.5-v5-apache](Dockerfile.apache) | `8.5.x` | fat | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-apache) -| [thecodingmachine/php:8.5-v5-apache-node22](Dockerfile.apache.node) | `8.5.x` | fat | apache | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-apache-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-apache-node22) -| [thecodingmachine/php:8.5-v5-apache-node24](Dockerfile.apache.node) | `8.5.x` | fat | apache | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-apache-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-apache-node24) -| [thecodingmachine/php:8.5-v5-apache-node26](Dockerfile.apache.node) | `8.5.x` | fat | apache | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-apache-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-apache-node26) -| [thecodingmachine/php:8.5-v5-fpm](Dockerfile.fpm) | `8.5.x` | fat | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-fpm) -| [thecodingmachine/php:8.5-v5-fpm-node22](Dockerfile.fpm.node) | `8.5.x` | fat | fpm | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-fpm-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-fpm-node22) -| [thecodingmachine/php:8.5-v5-fpm-node24](Dockerfile.fpm.node) | `8.5.x` | fat | fpm | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-fpm-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-fpm-node24) -| [thecodingmachine/php:8.5-v5-fpm-node26](Dockerfile.fpm.node) | `8.5.x` | fat | fpm | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-fpm-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-fpm-node26) -| [thecodingmachine/php:8.5-v5-cli](Dockerfile.cli) | `8.5.x` | fat | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-cli) -| [thecodingmachine/php:8.5-v5-cli-node22](Dockerfile.cli.node) | `8.5.x` | fat | cli | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-cli-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-cli-node22) -| [thecodingmachine/php:8.5-v5-cli-node24](Dockerfile.cli.node) | `8.5.x` | fat | cli | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-cli-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-cli-node24) -| [thecodingmachine/php:8.5-v5-cli-node26](Dockerfile.cli.node) | `8.5.x` | fat | cli | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-cli-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-cli-node26) -| [thecodingmachine/php:8.5-v5-slim-apache](Dockerfile.slim.apache) | `8.5.x` | slim | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-slim-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-slim-apache) -| [thecodingmachine/php:8.5-v5-slim-fpm](Dockerfile.slim.fpm) | `8.5.x` | slim | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-slim-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-slim-fpm) -| [thecodingmachine/php:8.5-v5-slim-cli](Dockerfile.slim.cli) | `8.5.x` | slim | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.5-v5-slim-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.5-v5-slim-cli) -| [thecodingmachine/php:8.4-v5-apache](Dockerfile.apache) | `8.4.x` | fat | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-apache) -| [thecodingmachine/php:8.4-v5-apache-node22](Dockerfile.apache.node) | `8.4.x` | fat | apache | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-apache-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-apache-node22) -| [thecodingmachine/php:8.4-v5-apache-node24](Dockerfile.apache.node) | `8.4.x` | fat | apache | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-apache-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-apache-node24) -| [thecodingmachine/php:8.4-v5-apache-node26](Dockerfile.apache.node) | `8.4.x` | fat | apache | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-apache-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-apache-node26) -| [thecodingmachine/php:8.4-v5-fpm](Dockerfile.fpm) | `8.4.x` | fat | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-fpm) -| [thecodingmachine/php:8.4-v5-fpm-node22](Dockerfile.fpm.node) | `8.4.x` | fat | fpm | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-fpm-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-fpm-node22) -| [thecodingmachine/php:8.4-v5-fpm-node24](Dockerfile.fpm.node) | `8.4.x` | fat | fpm | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-fpm-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-fpm-node24) -| [thecodingmachine/php:8.4-v5-fpm-node26](Dockerfile.fpm.node) | `8.4.x` | fat | fpm | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-fpm-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-fpm-node26) -| [thecodingmachine/php:8.4-v5-cli](Dockerfile.cli) | `8.4.x` | fat | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-cli) -| [thecodingmachine/php:8.4-v5-cli-node22](Dockerfile.cli.node) | `8.4.x` | fat | cli | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-cli-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-cli-node22) -| [thecodingmachine/php:8.4-v5-cli-node24](Dockerfile.cli.node) | `8.4.x` | fat | cli | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-cli-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-cli-node24) -| [thecodingmachine/php:8.4-v5-cli-node26](Dockerfile.cli.node) | `8.4.x` | fat | cli | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-cli-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-cli-node26) -| [thecodingmachine/php:8.4-v5-slim-apache](Dockerfile.slim.apache) | `8.4.x` | slim | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-slim-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-slim-apache) -| [thecodingmachine/php:8.4-v5-slim-fpm](Dockerfile.slim.fpm) | `8.4.x` | slim | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-slim-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-slim-fpm) -| [thecodingmachine/php:8.4-v5-slim-cli](Dockerfile.slim.cli) | `8.4.x` | slim | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.4-v5-slim-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.4-v5-slim-cli) -| [thecodingmachine/php:8.3-v5-apache](Dockerfile.apache) | `8.3.x` | fat | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-apache) -| [thecodingmachine/php:8.3-v5-apache-node22](Dockerfile.apache.node) | `8.3.x` | fat | apache | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-apache-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-apache-node22) -| [thecodingmachine/php:8.3-v5-apache-node24](Dockerfile.apache.node) | `8.3.x` | fat | apache | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-apache-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-apache-node24) -| [thecodingmachine/php:8.3-v5-apache-node26](Dockerfile.apache.node) | `8.3.x` | fat | apache | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-apache-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-apache-node26) -| [thecodingmachine/php:8.3-v5-fpm](Dockerfile.fpm) | `8.3.x` | fat | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-fpm) -| [thecodingmachine/php:8.3-v5-fpm-node22](Dockerfile.fpm.node) | `8.3.x` | fat | fpm | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-fpm-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-fpm-node22) -| [thecodingmachine/php:8.3-v5-fpm-node24](Dockerfile.fpm.node) | `8.3.x` | fat | fpm | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-fpm-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-fpm-node24) -| [thecodingmachine/php:8.3-v5-fpm-node26](Dockerfile.fpm.node) | `8.3.x` | fat | fpm | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-fpm-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-fpm-node26) -| [thecodingmachine/php:8.3-v5-cli](Dockerfile.cli) | `8.3.x` | fat | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-cli) -| [thecodingmachine/php:8.3-v5-cli-node22](Dockerfile.cli.node) | `8.3.x` | fat | cli | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-cli-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-cli-node22) -| [thecodingmachine/php:8.3-v5-cli-node24](Dockerfile.cli.node) | `8.3.x` | fat | cli | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-cli-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-cli-node24) -| [thecodingmachine/php:8.3-v5-cli-node26](Dockerfile.cli.node) | `8.3.x` | fat | cli | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-cli-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-cli-node26) -| [thecodingmachine/php:8.3-v5-slim-apache](Dockerfile.slim.apache) | `8.3.x` | slim | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-slim-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-slim-apache) -| [thecodingmachine/php:8.3-v5-slim-fpm](Dockerfile.slim.fpm) | `8.3.x` | slim | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-slim-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-slim-fpm) -| [thecodingmachine/php:8.3-v5-slim-cli](Dockerfile.slim.cli) | `8.3.x` | slim | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.3-v5-slim-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.3-v5-slim-cli) -| [thecodingmachine/php:8.2-v5-apache](Dockerfile.apache) | `8.2.x` | fat | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-apache) -| [thecodingmachine/php:8.2-v5-apache-node22](Dockerfile.apache.node) | `8.2.x` | fat | apache | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-apache-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-apache-node22) -| [thecodingmachine/php:8.2-v5-apache-node24](Dockerfile.apache.node) | `8.2.x` | fat | apache | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-apache-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-apache-node24) -| [thecodingmachine/php:8.2-v5-apache-node26](Dockerfile.apache.node) | `8.2.x` | fat | apache | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-apache-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-apache-node26) -| [thecodingmachine/php:8.2-v5-fpm](Dockerfile.fpm) | `8.2.x` | fat | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-fpm) -| [thecodingmachine/php:8.2-v5-fpm-node22](Dockerfile.fpm.node) | `8.2.x` | fat | fpm | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-fpm-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-fpm-node22) -| [thecodingmachine/php:8.2-v5-fpm-node24](Dockerfile.fpm.node) | `8.2.x` | fat | fpm | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-fpm-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-fpm-node24) -| [thecodingmachine/php:8.2-v5-fpm-node26](Dockerfile.fpm.node) | `8.2.x` | fat | fpm | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-fpm-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-fpm-node26) -| [thecodingmachine/php:8.2-v5-cli](Dockerfile.cli) | `8.2.x` | fat | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-cli) -| [thecodingmachine/php:8.2-v5-cli-node22](Dockerfile.cli.node) | `8.2.x` | fat | cli | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-cli-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-cli-node22) -| [thecodingmachine/php:8.2-v5-cli-node24](Dockerfile.cli.node) | `8.2.x` | fat | cli | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-cli-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-cli-node24) -| [thecodingmachine/php:8.2-v5-cli-node26](Dockerfile.cli.node) | `8.2.x` | fat | cli | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-cli-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-cli-node26) -| [thecodingmachine/php:8.2-v5-slim-apache](Dockerfile.slim.apache) | `8.2.x` | slim | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-slim-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-slim-apache) -| [thecodingmachine/php:8.2-v5-slim-fpm](Dockerfile.slim.fpm) | `8.2.x` | slim | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-slim-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-slim-fpm) -| [thecodingmachine/php:8.2-v5-slim-cli](Dockerfile.slim.cli) | `8.2.x` | slim | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.2-v5-slim-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.2-v5-slim-cli) -| [thecodingmachine/php:8.1-v5-apache](Dockerfile.apache) | `8.1.x` | fat | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-apache) -| [thecodingmachine/php:8.1-v5-apache-node20](Dockerfile.apache.node) | `8.1.x` | fat | apache | `20.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-apache-node20.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-apache-node20) -| [thecodingmachine/php:8.1-v5-apache-node22](Dockerfile.apache.node) | `8.1.x` | fat | apache | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-apache-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-apache-node22) -| [thecodingmachine/php:8.1-v5-apache-node24](Dockerfile.apache.node) | `8.1.x` | fat | apache | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-apache-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-apache-node24) -| [thecodingmachine/php:8.1-v5-apache-node26](Dockerfile.apache.node) | `8.1.x` | fat | apache | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-apache-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-apache-node26) -| [thecodingmachine/php:8.1-v5-fpm](Dockerfile.fpm) | `8.1.x` | fat | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-fpm) -| [thecodingmachine/php:8.1-v5-fpm-node20](Dockerfile.fpm.node) | `8.1.x` | fat | fpm | `20.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-fpm-node20.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-fpm-node20) -| [thecodingmachine/php:8.1-v5-fpm-node22](Dockerfile.fpm.node) | `8.1.x` | fat | fpm | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-fpm-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-fpm-node22) -| [thecodingmachine/php:8.1-v5-fpm-node24](Dockerfile.fpm.node) | `8.1.x` | fat | fpm | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-fpm-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-fpm-node24) -| [thecodingmachine/php:8.1-v5-fpm-node26](Dockerfile.fpm.node) | `8.1.x` | fat | fpm | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-fpm-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-fpm-node26) -| [thecodingmachine/php:8.1-v5-cli](Dockerfile.cli) | `8.1.x` | fat | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-cli) -| [thecodingmachine/php:8.1-v5-cli-node20](Dockerfile.cli.node) | `8.1.x` | fat | cli | `20.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-cli-node20.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-cli-node20) -| [thecodingmachine/php:8.1-v5-cli-node22](Dockerfile.cli.node) | `8.1.x` | fat | cli | `22.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-cli-node22.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-cli-node22) -| [thecodingmachine/php:8.1-v5-cli-node24](Dockerfile.cli.node) | `8.1.x` | fat | cli | `24.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-cli-node24.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-cli-node24) -| [thecodingmachine/php:8.1-v5-cli-node26](Dockerfile.cli.node) | `8.1.x` | fat | cli | `26.x` | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-cli-node26.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-cli-node26) -| [thecodingmachine/php:8.1-v5-slim-apache](Dockerfile.slim.apache) | `8.1.x` | slim | apache | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-slim-apache.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-slim-apache) -| [thecodingmachine/php:8.1-v5-slim-fpm](Dockerfile.slim.fpm) | `8.1.x` | slim | fpm | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-slim-fpm.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-slim-fpm) -| [thecodingmachine/php:8.1-v5-slim-cli](Dockerfile.slim.cli) | `8.1.x` | slim | cli | *N/A* | [![](https://images.microbadger.com/badges/image/thecodingmachine/php:8.1-v5-slim-cli.svg)](https://microbadger.com/images/thecodingmachine/php:8.1-v5-slim-cli) - - - -Note: we also tag patch releases of PHP versions. So you can specify a specific patch release using thecodingmachine/php:**8.4.1**-v5-cli for instance. -However, unless you have a **very specific need** (for instance if the latest patch release of PHP introduced regressions), believe you have no valid reason to ask explicitly for 8.4.1 for instance. -When 8.4.2 is out, you certainly want to upgrade automatically to this patch release since patch releases contain only bugfixes. -Also, we automatically rebuild X.Y images every week, but only the latest X.Y.Z patch release gets a rebuild. The other patch releases are frozen in time and will contain bugs and security issues. So use those with great care. - -[Major].[minor] images are automatically updated when a new patch version of PHP is released, so the PHP 8.4 image will always contain the most up-to-date version of the PHP 8.4.x branch. +A tag reads `-v5-[slim-][-node]`, for PHP 8.6 to 8.1 and NodeJS 22, 24 and 26. +In production, prefer the **slim** image: it contains only the extensions you list, so it is smaller and exposes less; +the **fat** image is handy in development. +The [Images page](https://thecodingmachine.github.io/docker-images-php/images.html) builds the tag, the Dockerfile and +the `compose.yml` for your use, and lists all the tags (also [on GitHub](docs/images.md)). ## Supported versions @@ -168,32 +80,32 @@ The images are based on Ubuntu 24.04, with PHP from the [Ondřej Surý's PHP rep Example with CLI: ```bash -$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.4-v5-cli php your-script.php +$ docker run -it --rm --name my-running-script -v "$PWD":/usr/src/app thecodingmachine/php:8.6-v5-cli php your-script.php ``` Example with PHP-FPM and its built-in Apache (in the same container), recommended to serve a web application: ```bash -$ docker run -p 80:80 --rm --name my-apache-fpm-app -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-fpm +$ docker run -p 80:80 --rm --name my-apache-fpm-app -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm ``` Example with PHP-FPM alone, behind your own web server: ```bash -$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-fpm +$ docker run -p 9000:9000 --rm --name my-php-fpm -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm ``` Example with Apache and `mod_php`: ```bash -$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-apache +$ docker run -p 80:80 --rm --name my-apache-php-app -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-apache ``` Example with Apache + Node 24.x in a Dockerfile: **Dockerfile** ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache-node24 +FROM thecodingmachine/php:8.6-v5-apache-node24 COPY src/ /var/www/html/ RUN composer install @@ -203,6 +115,8 @@ RUN npm run build ## Documentation +The documentation is also on the [documentation site](https://thecodingmachine.github.io/docker-images-php/), in English and in French. + Most features are configured with environment variables: | Topic | Content | Main variables | diff --git a/docs/_config.yml b/docs/_config.yml index 3e14d81..81fff99 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1,3 +1,9 @@ title: thecodingmachine/php description: General purpose PHP images for Docker baseurl: /docker-images-php +description_fr: Images PHP généralistes pour Docker +defaults: + - scope: + path: fr + values: + lang: fr diff --git a/docs/_data/nav.yml b/docs/_data/nav.yml index fbe9b9f..f8e9a4d 100644 --- a/docs/_data/nav.yml +++ b/docs/_data/nav.yml @@ -1,32 +1,55 @@ +# title_fr: the French title; bilingual: one page in both languages, French with #lang=fr, instead of a page under /fr/ - title: Start + title_fr: Démarrer items: - title: Overview + title_fr: Vue d'ensemble url: / - title: Variants + title_fr: Variantes url: /variants.html -- title: Serve and size + - title: Images + title_fr: Images + url: /images.html +- title: Web server and tuning + title_fr: Serveur web et tuning items: - title: Serving with the fpm variant + title_fr: La variante fpm url: /fpm.html - title: Tuning simulator + title_fr: Simulateur de tuning url: /tuning/ + bilingual: true - title: Behind a reverse proxy + title_fr: Derrière un reverse proxy url: /reverse-proxy/ + bilingual: true - title: Configure + title_fr: Configurer items: - title: PHP extensions + title_fr: Extensions PHP url: /extensions.html - title: PHP configuration + title_fr: Configuration de PHP url: /php-configuration.html - title: Processes, cron, daemons + title_fr: Processus, cron, daemons url: /processes.html - title: Debugging, profiling, coverage + title_fr: Debugging, profiling, coverage url: /debugging/ + bilingual: true - title: Advanced features + title_fr: Fonctions avancées url: /advanced.html - title: Project + title_fr: Projet items: - title: Security + title_fr: Sécurité url: /security.html - title: Contributing + title_fr: Contribuer url: /contributing.html diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index 577201d..4bd52a4 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -1,42 +1,140 @@ - +{%- assign lang = page.lang | default: 'en' -%} +{%- if lang == 'fr' -%}{%- assign en_url = page.url | remove_first: '/fr' -%}{%- assign fr_url = page.url -%} +{%- else -%}{%- assign en_url = page.url -%}{%- assign fr_url = page.url | prepend: '/fr' -%}{%- endif -%} +{%- assign title = page.title -%}{%- if lang == 'fr' and page.title_fr -%}{%- assign title = page.title_fr -%}{%- endif %} + -{% if page.title and page.url != "/" %}{{ page.title }} · {% endif %}{{ site.title }} - +{% if title and page.url != "/" and page.url != "/fr/" %}{{ title }} · {% endif %}{{ site.title }} + +{%- if page.bilingual %} + + +{%- else %} + + +{%- endif %} - +
- thecodingmachine/php - v5 documentation - GitHub +
+ {%- if page.bilingual %} + TheCodingMachinePHP images + TheCodingMachineImages PHP + v5 docsdoc v5 + {%- else %} + TheCodingMachine{% if lang == 'fr' %}Images PHP{% else %}PHP images{% endif %} + {% if lang == 'fr' %}doc v5{% else %}v5 docs{% endif %} + {%- endif %} + + GitHub +
+{%- if page.wide %} +{{ content }} +{%- else %} +
{{ content }} +
+{%- endif %}
+{%- if page.name == 'images.md' %} + +{%- endif %} diff --git a/docs/advanced.md b/docs/advanced.md index 52ddb8f..19b346b 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -15,6 +15,8 @@ ID of this owner. The commands, Apache and PHP-FPM then run as `docker`: - your PHP application can edit any file of your project; - you can edit any file created by the container. +
The docker user takes the UID of the owner of the mounted project
+ If this ID is already used by a system account of the image (e.g. `998`, used by `systemd-network` in the image and often by the `gitlab-runner` user on CI hosts), this system account is moved to another ID: the commands are still run by the `docker` user. @@ -31,14 +33,14 @@ them through a security hole, they can run any PHP code. Run Apache as `www-data ## NodeJS -The fat images have NodeJS variants (e.g. `thecodingmachine/php:8.4-v5-apache-node24`), see the +The fat images have NodeJS variants (e.g. `thecodingmachine/php:8.6-v5-apache-node24`), see the [list of images](../README.md#images). With a slim image, the `NODE_VERSION` ARG installs NodeJS (with npm and yarn) during the build: ```Dockerfile ARG NODE_VERSION=24 -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ``` The `ARG NODE_VERSION` instruction must be written before the `FROM`. This is not a typo. @@ -60,7 +62,7 @@ during the build instead, with an ARG before the `FROM`: ```Dockerfile ARG COMPOSER_VERSION=2.4.4 -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ``` ## Locales @@ -79,7 +81,7 @@ the `FROM`: ```Dockerfile ARG INSTALL_LOCALES=1 -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ``` ## SSH private keys @@ -92,7 +94,7 @@ If your project depends on a [package stored in a private Git repository](https: ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache volumes: - ~/.ssh:/home/docker/.ssh ``` @@ -100,7 +102,7 @@ services: **In a Dockerfile**, pass the key and the signature of the server (`ssh-keyscan myserver.com`) as build arguments: ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache +FROM thecodingmachine/php:8.6-v5-apache ARG SSH_PRIVATE_KEY ARG SSH_KNOWN_HOSTS @@ -134,7 +136,7 @@ kind: Pod spec: containers: - name: foobar - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache securityContext: allowPrivilegeEscalation: true # never use "false" here ``` diff --git a/docs/assets/css/site.css b/docs/assets/css/site.css index 7597a96..d50aa9f 100644 --- a/docs/assets/css/site.css +++ b/docs/assets/css/site.css @@ -1,27 +1,37 @@ +@font-face { + font-family: "Open Sans"; font-style: normal; font-weight: 400 700; font-stretch: 100%; font-display: swap; + src: url(../fonts/open-sans-latin.woff2) format("woff2"); +} :root { - --bg: #f6f7f9; --panel: #ffffff; --ink: #1b1f24; --muted: #5d6673; --line: #dde1e6; --soft: #eef1f4; - --accent: #2f6fde; --ok: #1f8a4c; --warn: #b7791f; --bad: #c53030; + --bg: #f5f6f8; --panel: #ffffff; --ink: #0a1628; --muted: #5b6474; --line: #e1e5ea; --soft: #eef1f4; + --accent: #00805f; --on-accent: #ffffff; --ok: #1f8a4c; --warn: #b7791f; --bad: #c53030; --c-modphp: #d9534f; --c-apachefpm: #2f6fde; --c-nginxfpm: #1f8a4c; --c-franken: #8a63d2; + --navy: #0a1628; --navy-2: #001247; --mint: #00ecae; + --code-bg: #0d1b2e; --code-ink: #dfe7f1; --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; + --sans: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; } @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { - --bg: #12151a; --panel: #1a1e25; --ink: #e6e9ee; --muted: #9aa3af; --line: #2c323c; --soft: #222833; - --accent: #6a9cf0; --ok: #4cc27f; --warn: #e0a84a; --bad: #f07171; + --bg: #0b1220; --panel: #111a2b; --ink: #e6e9ee; --muted: #9aa6b8; --line: #24314a; --soft: #19243a; + --accent: #2fe0ad; --on-accent: #06281f; --ok: #4cc27f; --warn: #e0a84a; --bad: #f07171; --c-modphp: #f07171; --c-apachefpm: #6a9cf0; --c-nginxfpm: #4cc27f; --c-franken: #b393f0; + --code-bg: #070d18; --code-ink: #dfe7f1; } } :root[data-theme="dark"] { - --bg: #12151a; --panel: #1a1e25; --ink: #e6e9ee; --muted: #9aa3af; --line: #2c323c; --soft: #222833; - --accent: #6a9cf0; --ok: #4cc27f; --warn: #e0a84a; --bad: #f07171; + --bg: #0b1220; --panel: #111a2b; --ink: #e6e9ee; --muted: #9aa6b8; --line: #24314a; --soft: #19243a; + --accent: #2fe0ad; --on-accent: #06281f; --ok: #4cc27f; --warn: #e0a84a; --bad: #f07171; --c-modphp: #f07171; --c-apachefpm: #6a9cf0; --c-nginxfpm: #4cc27f; --c-franken: #b393f0; + --code-bg: #070d18; --code-ink: #dfe7f1; } * { box-sizing: border-box; } -body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; } -a { color: var(--accent); } -code { font: 0.9em var(--mono); background: var(--soft); padding: 1px 4px; border-radius: 4px; } -pre { background: var(--soft); border-radius: 8px; padding: 12px; overflow-x: auto; font: 13px/1.5 var(--mono); } -pre code { background: none; padding: 0; } +html { scroll-padding-top: 80px; } +body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; } +a { color: var(--accent); text-underline-offset: 2px; } +code { font: 0.88em var(--mono); background: var(--soft); padding: 1px 5px; border-radius: 4px; } +pre { background: var(--soft); border-radius: 8px; padding: 12px; overflow-x: auto; font: 13px/1.55 var(--mono); } +pre code { background: none; padding: 0; font-size: inherit; } table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; } td, th { border-bottom: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; } th { color: var(--muted); font-weight: 600; } @@ -29,26 +39,140 @@ h1 { font-size: 28px; line-height: 1.25; margin: 0 0 12px; letter-spacing: -0.01 h2 { font-size: 21px; margin: 32px 0 10px; } h3 { font-size: 17px; margin: 24px 0 8px; } -header.site { display: flex; align-items: baseline; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--panel); } -header.site .brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 16px; } -header.site .release { color: var(--muted); font-size: 13px; } -header.site .repo { margin-left: auto; font-size: 14px; } -.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 32px; max-width: 1200px; margin: 0 auto; padding: 0 16px; } -body.wide .layout { max-width: 1520px; } -nav.side { padding-top: 24px; font-size: 14px; } +/* Header: the colors of TheCodingMachine */ +header.site { position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff; border-bottom: 3px solid var(--mint); } +header.site .site-bar { display: flex; align-items: center; gap: 14px; max-width: 1480px; margin: 0 auto; padding: 10px 24px; } +header.site .brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; } +header.site .brand img { height: 26px; width: auto; display: block; } +header.site .brand .sep { width: 1px; height: 22px; background: rgba(255, 255, 255, 0.25); } +header.site .release { color: #0a1628; background: var(--mint); font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; } +header.site .langs { margin-left: auto; display: flex; gap: 2px; font-size: 13px; } +header.site .langs a { padding: 3px 10px; border-radius: 6px; color: rgba(255, 255, 255, 0.7); text-decoration: none; } +header.site .langs a:hover { color: #fff; } +header.site .langs a[aria-current] { background: rgba(0, 236, 174, 0.15); color: var(--mint); font-weight: 600; } +header.site .repo { display: flex; align-items: center; gap: 6px; color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; } +header.site .repo svg { width: 18px; height: 18px; fill: currentColor; } +/* Pages in both languages: data-l="en" and data-l="fr" elements, the language of the body shows */ +body[data-lang=fr] [data-l=en], body:not([data-lang=fr]) [data-l=fr] { display: none !important; } + +/* Same frame on every page: the menu does not move, only the reading column is narrower on text pages */ +.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 48px; max-width: 1480px; margin: 0 auto; padding: 0 24px; } +nav.side { position: sticky; top: 64px; align-self: start; max-height: calc(100vh - 64px); overflow-y: auto; padding: 28px 0 24px; font-size: 14px; } nav.side summary { display: none; } -nav.side h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 16px 0 4px; } +nav.side h4 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 20px 0 6px; padding-left: 12px; } +nav.side h4:first-of-type { margin-top: 0; } nav.side ul { list-style: none; padding: 0; margin: 0; } -nav.side li a { display: block; padding: 3px 8px; border-radius: 6px; color: var(--ink); text-decoration: none; } +nav.side li a { display: block; padding: 5px 12px; border-left: 3px solid transparent; border-radius: 0 6px 6px 0; color: var(--ink); text-decoration: none; } nav.side li a:hover { background: var(--soft); } -nav.side li a[aria-current] { background: var(--soft); color: var(--accent); font-weight: 600; } -main.content { padding: 24px 0 48px; min-width: 0; } -body:not(.wide) main.content { max-width: 860px; } -footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 16px; text-align: center; } - -@media (max-width: 860px) { - .layout { grid-template-columns: minmax(0, 1fr); gap: 0; } - nav.side { padding-top: 12px; } +nav.side li a[aria-current] { background: var(--panel); border-left-color: var(--mint); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(10, 22, 40, 0.06); } +main.content { padding: 32px 0 64px; min-width: 0; } +footer.site { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; } +footer.site .site-bar { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; max-width: 1480px; margin: 0 auto; padding: 20px 24px; } +footer.site .by { margin-left: auto; display: flex; align-items: center; gap: 8px; } +footer.site .by img { height: 18px; background: var(--navy); padding: 4px 6px; border-radius: 4px; box-sizing: content-box; } + +/* Text pages */ +.prose { max-width: 800px; font-size: 16px; line-height: 1.7; } +main.content > h1 { padding-bottom: 14px; margin-bottom: 16px; position: relative; } +main.content > h1::after, .prose h1::after { content: ""; position: absolute; left: 0; bottom: 0; width: 56px; height: 4px; border-radius: 2px; background: var(--mint); } +.prose h1 { font-size: 32px; line-height: 1.2; margin: 0 0 20px; padding-bottom: 14px; position: relative; } +.prose h2 { font-size: 23px; line-height: 1.3; margin: 56px 0 14px; padding-top: 28px; border-top: 1px solid var(--line); } +.prose .hero + h2, .prose h1 + h2, .prose h1 + p + h2 { border-top: 0; padding-top: 0; margin-top: 32px; } +.prose h3 { font-size: 18px; margin: 32px 0 8px; } +.prose h2, .prose h3 { scroll-margin-top: 80px; } +.prose p, .prose ul, .prose ol { margin: 0 0 16px; } +.prose li { margin: 4px 0; } +.prose li > p { margin: 0 0 8px; } +.prose strong { font-weight: 700; } +.prose a { font-weight: 500; } +.prose h2 a, .prose h3 a { color: inherit; text-decoration: none; } +.prose :not(pre) > code { color: var(--ink); background: var(--soft); border: 1px solid var(--line); padding: 0 5px; } +.prose table { margin: 0 0 20px; font-size: 15px; } +.prose th { background: var(--soft); color: var(--ink); } +.prose blockquote { margin: 0 0 16px; padding: 10px 16px; border-left: 4px solid var(--mint); background: var(--panel); border-radius: 0 8px 8px 0; color: var(--muted); } +.prose blockquote p:last-child { margin: 0; } +.prose img { max-width: 100%; height: auto; } +.prose figure { margin: 8px 0 28px; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); text-align: center; } +.prose figure img { display: block; margin: 0 auto; } +.prose figcaption { margin-top: 10px; font-size: 14px; color: var(--muted); } + +/* Code blocks: dark, on every page with Markdown code */ +.highlighter-rouge { margin: 0 0 20px; } +div.highlight, .prose pre { background: var(--code-bg); color: var(--code-ink); border-radius: 8px; } +div.highlight pre.highlight, .prose pre { margin: 0; padding: 14px 16px; background: transparent; color: var(--code-ink); font-size: 13.5px; line-height: 1.6; } +.prose li .highlighter-rouge { margin: 8px 0 12px; } +.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .sr { color: #7f8ea3; font-style: italic; } +.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sh, .highlight .se { color: #9be7c4; } +.highlight .k, .highlight .kd, .highlight .kn, .highlight .kr, .highlight .nb, .highlight .nt { color: #7cc4ff; } +.highlight .nv, .highlight .vi, .highlight .na, .highlight .py { color: var(--mint); } +.highlight .m, .highlight .mi, .highlight .mf, .highlight .no { color: #ffc874; } +.highlight .o, .highlight .p, .highlight .pi { color: #b6c2d1; } +.highlight .err { color: inherit; background: none; } + +/* Copy buttons */ +div.highlight { position: relative; } +button.copy { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 6px; background: rgba(255, 255, 255, 0.06) center / 16px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b6c2d1' stroke-width='2'%3E%3Crect x='9' y='9' width='12' height='12' rx='2'/%3E%3Cpath d='M5 15V5a2 2 0 0 1 2-2h10'/%3E%3C/svg%3E"); cursor: pointer; opacity: 0; transition: opacity 0.15s; } +div.highlight:hover button.copy, button.copy:focus-visible { opacity: 1; } +button.copy.copied { opacity: 1; border-color: var(--mint); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2300ecae' stroke-width='2.5'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E"); } +.prose td > code.tag-copy { cursor: pointer; white-space: nowrap; display: inline-block; margin: 2px 0; transition: border-color 0.15s, background 0.15s; } +.prose td > code.tag-copy:hover, .prose td > code.tag-copy:focus-visible { border-color: var(--accent); outline: none; } +.prose td > code.tag-copy.copied { border-color: var(--mint); background: color-mix(in srgb, var(--mint) 18%, var(--panel)); } +.prose td > code.tag-copy.copied::after { content: " ✓"; color: var(--accent); } + +/* Tag picker of the Images page */ +#tag-picker { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid var(--mint); border-radius: var(--radius); padding: 18px 20px; margin: 8px 0 28px; font-size: 14px; line-height: 1.5; } +#tag-picker:empty { display: none; } +.tp-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 10px; align-items: baseline; margin-bottom: 10px; } +.tp-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); } +.tp-chips { display: flex; flex-wrap: wrap; gap: 6px; } +.tp-chips button { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 3px 12px; cursor: pointer; } +.tp-chips button:hover:not(:disabled) { border-color: var(--accent); } +.tp-chips button.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); } +.tp-chips button:disabled { opacity: 0.4; cursor: default; } +.tp-chips button.dim:not(.on) { color: var(--muted); border-style: dashed; background: transparent; } +.tp-chips small { font-size: 10px; font-weight: 700; opacity: 0.75; } +.tp-out { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); } +.tp-tag, .tp-cmd { display: flex; align-items: center; gap: 10px; background: var(--code-bg); border-radius: 8px; padding: 10px 10px 10px 14px; } +#tag-picker .tp-tag code, #tag-picker .tp-cmd code { flex: 1; min-width: 0; background: none; border: 0; padding: 0; color: var(--code-ink); white-space: pre-wrap; overflow-wrap: anywhere; } +#tag-picker .tp-tag code { font-size: 17px; font-weight: 600; color: var(--mint); } +#tag-picker .tp-cmd code { font-size: 13px; line-height: 1.6; } +.tp-note { margin: 8px 0 10px; color: var(--muted); font-size: 13px; } +.tp-copy { flex: none; font: inherit; font-size: 12px; font-weight: 600; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.08); color: #fff; border-radius: 6px; padding: 4px 10px; cursor: pointer; } +.tp-copy:hover { border-color: var(--mint); } +.tp-node { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; } +.tp-input { font: 13px var(--mono); padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); } +.tp-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; } +.tp-ext { width: 100%; max-width: 420px; } +.tp-tabs { margin: 14px 0 8px; } +#tag-picker .tp-cmd { align-items: flex-start; } +#tag-picker .tp-cmd code { white-space: pre; overflow-x: auto; overflow-wrap: normal; padding-bottom: 8px; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.25) transparent; } +@media (max-width: 600px) { .tp-row { grid-template-columns: minmax(0, 1fr); gap: 4px; } } + +/* Home: one card per page */ +.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 8px 0 28px; } +.home-cards a.card { display: block; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; font-weight: 400; transition: border-color 0.15s, transform 0.15s; } +.home-cards a.card:hover { border-color: var(--mint); transform: translateY(-1px); } +.home-cards a.card b { display: block; font-size: 16px; margin-bottom: 4px; } +.home-cards a.card span { display: block; font-size: 14px; line-height: 1.5; color: var(--muted); } +.home-cards a.card .tag { display: inline-block; margin-top: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); } +.hero { background: var(--navy); color: #e6edf5; border-radius: 14px; padding: 28px 30px; margin: 0 0 32px; position: relative; overflow: hidden; } +.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(0, 236, 174, 0.28), transparent 70%); } +.hero h1 { color: #fff; margin: 0 0 10px; padding: 0; font-size: 30px; } +.hero h1::after { display: none; } +.hero h1 em { font-style: normal; color: var(--mint); } +.hero p { margin: 0 0 16px; max-width: 640px; color: #c3cedb; } +.hero pre { position: relative; z-index: 1; margin: 0; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.08); color: var(--code-ink); } +.hero .chips { text-decoration: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; } +.hero .chips span { font: 12px var(--mono); padding: 2px 8px; border-radius: 999px; background: rgba(0, 236, 174, 0.12); color: var(--mint); } + +@media (max-width: 900px) { + .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 0 16px; } + header.site .site-bar { padding: 10px 16px; gap: 10px; } + header.site .brand .name, header.site .brand .sep, header.site .release { display: none; } + nav.side { position: static; max-height: none; padding-top: 14px; } nav.side summary { display: block; cursor: pointer; font-weight: 600; } nav.side details:not([open]) h4, nav.side details:not([open]) ul { display: none; } + .prose { font-size: 15px; } + .prose h1 { font-size: 26px; } + footer.site .by { margin-left: 0; } } diff --git a/docs/assets/fonts/OFL.txt b/docs/assets/fonts/OFL.txt new file mode 100644 index 0000000..2e76eef --- /dev/null +++ b/docs/assets/fonts/OFL.txt @@ -0,0 +1,88 @@ +Copyright 2020 The Open Sans Project Authors (https://github.com/googlefonts/opensans) + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font +creation efforts of academic and linguistic communities, and to +provide a free and open framework in which fonts may be shared and +improved in partnership with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply to +any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software +components as distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, +deleting, or substituting -- in part or in whole -- any of the +components of the Original Version, by changing formats or by porting +the Font Software to a new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, +modify, redistribute, and sell modified and unmodified copies of the +Font Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, in +Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the +corresponding Copyright Holder. This restriction only applies to the +primary font name as presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created using +the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/assets/fonts/open-sans-latin.woff2 b/docs/assets/fonts/open-sans-latin.woff2 new file mode 100644 index 0000000..b5d54e7 Binary files /dev/null and b/docs/assets/fonts/open-sans-latin.woff2 differ diff --git a/docs/assets/img/images.fr.svg b/docs/assets/img/images.fr.svg new file mode 100644 index 0000000..1744017 --- /dev/null +++ b/docs/assets/img/images.fr.svg @@ -0,0 +1,8 @@ +Les images : 3 variantes, slim, fat et nodecliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composerextensions de base8.6-v5-slim-cli8.6-v5-slim-apache8.6-v5-slim-fpmfat+ extensions courantes+ Supercronic, locales8.6-v5-cli8.6-v5-apache8.6-v5-fpmnode+ NodeJSnpm, yarn8.6-v5-cli-node248.6-v5-apache-node248.6-v5-fpm-node24 diff --git a/docs/assets/img/images.svg b/docs/assets/img/images.svg new file mode 100644 index 0000000..52405c6 --- /dev/null +++ b/docs/assets/img/images.svg @@ -0,0 +1,8 @@ +The images: 3 variants, slim, fat and nodecliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composercore extensions8.6-v5-slim-cli8.6-v5-slim-apache8.6-v5-slim-fpmfat+ common extensions+ Supercronic, locales8.6-v5-cli8.6-v5-apache8.6-v5-fpmnode+ NodeJSnpm, yarn8.6-v5-cli-node248.6-v5-apache-node248.6-v5-fpm-node24 diff --git a/docs/assets/img/permissions.fr.svg b/docs/assets/img/permissions.fr.svg new file mode 100644 index 0000000..fc5b563 --- /dev/null +++ b/docs/assets/img/permissions.fr.svg @@ -0,0 +1,8 @@ +Permissions : l’utilisateur docker prend l’ID du propriétaire de votre projetVOTRE MACHINE~/projectpropriétaire : UID 1000vous : UID 1000bind mountCONTENEUR/var/www/html · /usr/src/apppropriétaire : UID 1000entrypoint : utilisateur docker → UID 1000Apache, PHP-FPM, composer… tournent sous docker→ les fichiers créés dans le conteneur vous appartiennent diff --git a/docs/assets/img/permissions.svg b/docs/assets/img/permissions.svg new file mode 100644 index 0000000..57bbb0d --- /dev/null +++ b/docs/assets/img/permissions.svg @@ -0,0 +1,8 @@ +Permissions: the docker user takes the ID of the owner of your projectYOUR MACHINE~/projectowner: UID 1000you: UID 1000bind mountCONTAINER/var/www/html · /usr/src/appowner: UID 1000entrypoint: docker user → UID 1000Apache, PHP-FPM, composer… run as docker→ files created in the container belong to you diff --git a/docs/assets/img/processes.fr.svg b/docs/assets/img/processes.fr.svg new file mode 100644 index 0000000..91299b0 --- /dev/null +++ b/docs/assets/img/processes.fr.svg @@ -0,0 +1,8 @@ +Ce qui se passe au démarrage d’un conteneurdocker runentrypointPHP, php.ini, extensionsApache, Composer, localescommandes de démarrageSTARTUP_COMMAND_*LANCÉS ENSEMBLEcommande principaleapache2 · php-fpm · php …tâches cronCRON_COMMAND_*daemonsDAEMON_COMMAND_*l’un d’eux s’arrête → les autres s’arrêtent → le conteneur s’arrête diff --git a/docs/assets/img/processes.svg b/docs/assets/img/processes.svg new file mode 100644 index 0000000..522c96f --- /dev/null +++ b/docs/assets/img/processes.svg @@ -0,0 +1,8 @@ +What happens when a container startsdocker runentrypointPHP, php.ini, extensionsApache, Composer, localesstartup commandsSTARTUP_COMMAND_*RUNNING TOGETHERmain commandapache2 · php-fpm · php …cron jobsCRON_COMMAND_*daemonsDAEMON_COMMAND_*one of them exits → the others stop → the container exits diff --git a/docs/assets/img/tcm-logo.svg b/docs/assets/img/tcm-logo.svg new file mode 100644 index 0000000..53ba73d --- /dev/null +++ b/docs/assets/img/tcm-logo.svg @@ -0,0 +1,38 @@ + + + TCM + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/assets/js/tag-picker.js b/docs/assets/js/tag-picker.js new file mode 100644 index 0000000..92eec1a --- /dev/null +++ b/docs/assets/js/tag-picker.js @@ -0,0 +1,150 @@ +// Image picker of the Images page: the tag, a docker run command, a Dockerfile and a compose.yml from a few choices +(() => { + const root = document.getElementById('tag-picker'); + if (!root) return; + const fr = document.documentElement.lang === 'fr'; + const T = (en, frText) => (fr ? frText : en); + const words = (s) => s.split(' ').filter(Boolean); + const versions = words(root.dataset.php); + const legacy = words(root.dataset.legacy); + const state = { php: root.dataset.defaultPhp, use: 'apache', type: 'slim', node: '', ext: 'apcu intl pdo_mysql', out: 'dockerfile' }; + + const USES = { + 'apache': { variant: 'apache', label: 'apache', note: T('Apache with mod_php, HTTP on port 80.', 'Apache avec mod_php, HTTP sur le port 80.') }, + 'fpm': { variant: 'fpm', label: 'fpm', note: T('PHP-FPM, FastCGI on port 9000: see the fpm variant to serve HTTP.', 'PHP-FPM, FastCGI sur le port 9000 : voir la variante fpm pour servir le HTTP.') }, + 'cli': { variant: 'cli', label: 'cli', note: T('Scripts, workers, CI: no web server.', 'Scripts, workers, CI : sans serveur web.') }, + }; + + const esc = (s) => s.replace(/&/g, '&').replace(/ words(legacy.includes(state.php) ? root.dataset.legacyNode : root.dataset.node); + const variant = () => USES[state.use].variant; + const dir = () => (variant() === 'cli' ? '/usr/src/app' : '/var/www/html'); + // NodeJS versions without a -node tag, installed from NodeSource by the Dockerfile + const others = () => words(root.dataset.otherNode || '').filter((n) => !published().includes(n)); + const nodeVersion = () => state.node; + // A fat image with a published NodeJS tag needs no install step + const nodeTag = () => state.type === 'fat' && published().includes(nodeVersion()); + const tag = () => { + if (state.type === 'slim') return `${state.php}-v5-slim-${variant()}`; + return `${state.php}-v5-${variant()}${nodeTag() ? '-node' + nodeVersion() : ''}`; + }; + const image = () => 'thecodingmachine/php:' + tag(); + // Only the tag is needed: fat image, no NodeJS or a published one + const tagOnly = () => state.type === 'fat' && (!nodeVersion() || nodeTag()); + + // One option per line, so the command fits the column + const runCommand = () => { + const opts = { + fpm: ['-p 9000:9000', '-v "$PWD":/var/www/html'], + apache: ['-p 80:80', '-v "$PWD":/var/www/html'], + cli: ['-it --rm', '-v "$PWD":/usr/src/app'], + }[state.use]; + return ['docker run ' + opts[0], ...opts.slice(1), image() + (state.use === 'cli' ? ' php your-script.php' : '')].join(' \\\n '); + }; + + const nodeInstall = (v) => [ + T(`# NodeJS ${v} from NodeSource: this fat image has no NodeJS ${v} tag`, `# NodeJS ${v} depuis NodeSource : cette image fat n'a pas de tag NodeJS ${v}`), + 'RUN sudo apt-get update \\', + ' && sudo apt-get install -y --no-install-recommends gnupg \\', + ' && sudo mkdir -p /etc/apt/keyrings \\', + ' && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \\', + ` && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${v}.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list \\`, + ' && sudo apt-get update \\', + ' && sudo apt-get install -y --no-install-recommends nodejs \\', + ...(+v >= 25 ? [' && sudo npm install -g corepack \\'] : []), + ' && sudo corepack enable && sudo corepack prepare yarn@stable --activate \\', + ' && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/*', + '', + ]; + + const dockerfile = () => { + const v = nodeVersion(); + const l = []; + if (state.type === 'slim') { + const ext = state.ext.trim().replace(/\s+/g, ' '); + l.push(T('# Before the FROM: the slim image installs them during the build', "# Avant le FROM : l'image slim les installe pendant le build")); + if (ext) l.push(`ARG PHP_EXTENSIONS="${ext}"`); + if (v) l.push(`ARG NODE_VERSION=${v}`); + if (!ext && !v) l.length = 0; + } + l.push(`FROM ${image()}`, ''); + if (state.type === 'fat' && v && !nodeTag()) l.push(...nodeInstall(v)); + const env = ['TEMPLATE_PHP_INI=production']; + if (state.type === 'fat') l.push(T('# Fat image: enable extensions with PHP_EXTENSION_=1, e.g. PHP_EXTENSION_INTL=1', '# Image fat : activez des extensions avec PHP_EXTENSION_=1, par ex. PHP_EXTENSION_INTL=1')); + l.push('ENV ' + env.join(' \\\n '), ''); + l.push(`COPY --chown=docker:docker . ${dir()}`); + l.push('RUN composer install --no-dev --optimize-autoloader' + (v ? ' \\\n && npm ci \\\n && npm run build' : '')); + if (state.use === 'cli') l.push('', 'CMD ["php", "your-script.php"]'); + return l.join('\n') + '\n'; + }; + + const compose = () => { + const l = ['services:', ' app:']; + if (tagOnly()) l.push(` image: ${image()}`); + else l.push(' build: .', T(' # the Dockerfile of the Dockerfile tab', " # le Dockerfile de l'onglet Dockerfile")); + if (state.use === 'apache') l.push(' ports:', ' - "80:80"'); + if (state.use === 'fpm') l.push(T(' # FastCGI on app:9000, see the fpm variant to serve HTTP', ' # FastCGI sur app:9000, voir la variante fpm pour servir le HTTP')); + if (state.use === 'cli') l.push(' command: php your-script.php'); + l.push(' volumes:', ` - .:${dir()}`); + return l.join('\n') + '\n'; + }; + + // An option with a title is a secondary choice, shown dimmer + const chips = (key, options) => `
` + options.map(([value, label, disabled, title]) => { + const cls = [state[key] === value ? 'on' : '', title ? 'dim' : ''].filter(Boolean).join(' '); + return ``; + }).join('') + '
'; + const copyBtn = (text) => ``; + const block = (text, cls) => `
${esc(text)}${copyBtn(text)}
`; + + const notes = () => { + const n = [USES[state.use].note]; + n.push(state.type === 'slim' + ? T('Slim: recommended in production, only the extensions you list.', 'Slim : recommandée en production, seulement les extensions que vous listez.') + : T('Fat: handy in development; in production, prefer the slim image.', 'Fat : pratique en développement ; en production, préférez l\'image slim.')); + if (legacy.includes(state.php)) n.push(T(`PHP ${state.php} is no longer maintained.`, `PHP ${state.php} n'est plus maintenu.`)); + if (state.type === 'fat' && nodeVersion() && !nodeTag()) n.push(T(`No fat image with NodeJS ${nodeVersion()}: the Dockerfile installs it.`, `Pas d'image fat avec NodeJS ${nodeVersion()} : le Dockerfile l'installe.`)); + return n.join(' '); + }; + + const render = () => { + if (state.node && !published().includes(state.node) && !others().includes(state.node)) state.node = ''; + if (state.out === 'run' && !tagOnly()) state.out = 'dockerfile'; + const outputs = [['dockerfile', 'Dockerfile'], ['compose', 'compose.yml'], ['run', 'docker run', !tagOnly()]]; + const out = { dockerfile: dockerfile, compose: compose, run: runCommand }[state.out](); + root.innerHTML = + `
${T('Variant', 'Variante')}${chips('use', Object.entries(USES).map(([k, u]) => [k, u.label]))}
` + + `
PHP${chips('php', versions.map((v) => [v, legacy.includes(v) ? `${v} EOL` : v]))}
` + + `
Image${chips('type', [['slim', T('slim: production', 'slim : production')], ['fat', T('fat: development', 'fat : développement')]])}
` + + (state.type === 'slim' ? `
${T('Extensions', 'Extensions')}
` : '') + + `
NodeJS
${chips('node', [['', T('none', 'aucun')], ...published().map((n) => [n, n]), ...others().map((n) => [n, n, false, T('No -node tag: installed by the Dockerfile', 'Pas de tag -node : installé par le Dockerfile')])])}
` + + `
${block(image(), 'tp-tag')}

${notes()}

` + + `
${chips('out', outputs)}
${block(out, 'tp-cmd')}
`; + }; + + root.addEventListener('click', (e) => { + const copy = e.target.closest('.tp-copy'); + if (copy) { + navigator.clipboard.writeText(copy.dataset.copy).then(() => { + copy.textContent = T('Copied', 'Copié'); + setTimeout(() => { copy.textContent = T('Copy', 'Copier'); }, 1200); + }); + return; + } + const b = e.target.closest('.tp-chips button'); + if (!b || b.disabled) return; + state[b.parentElement.dataset.key] = b.dataset.value; + render(); + }); + // Typing re-renders the outputs only, so the field keeps the focus + root.addEventListener('input', (e) => { + if (e.target.classList.contains('tp-ext')) state.ext = e.target.value; + else return; + const field = e.target, pos = field.selectionStart; + render(); + const again = root.querySelector('.tp-ext'); + again.focus(); + again.setSelectionRange(pos, pos); + }); + render(); +})(); diff --git a/docs/contributing.md b/docs/contributing.md index 60fcad4..f03d8c3 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -18,7 +18,9 @@ or `utils/README.blueprint.md`, then run: $ make blueprint ``` -The pages of the `docs` directory are not generated: edit them directly. +The pages of the `docs` directory are not generated, except `images.md` (`utils/images.blueprint.md`): edit them directly. Each English page has its French +translation in `docs/fr/` (same file name), to update with it; the interactive pages (`tuning/`, `reverse-proxy/`, +`debugging/`) hold both languages in the same file. The images of a PHP version share their first layers (see `utils/docker-bake.blueprint.hcl`): @@ -34,7 +36,7 @@ The tests use [bash_unit](https://github.com/pgrange/bash_unit) (see the [test s Build and test a PHP version (*cli*, *apache* and *fpm* variants): ```bash -$ make test-8.4 +$ make test-8.6 ``` `make test-quick` builds and tests the *cli* variant of the maintained PHP versions, without NodeJS. @@ -42,14 +44,14 @@ $ make test-8.4 To test images already built, run the test suite directly: ```bash -$ PHP_VERSION=8.4 BRANCH=v5 VARIANT=apache ./tests-suite/bash_unit -f tap ./tests-suite/*.sh +$ PHP_VERSION=8.6 BRANCH=v5 VARIANT=apache ./tests-suite/bash_unit -f tap ./tests-suite/*.sh ``` To run the test files of several variants in parallel, as the CI does (`TEST_JOBS` test files at the same time, 2 by default, with one log per test file): ```bash -$ PHP_VERSION=8.4 BRANCH=v5 VARIANTS="apache cli fpm" NODE_VERSIONS="22 24 26" ./tests-suite/run_tests.sh +$ PHP_VERSION=8.6 BRANCH=v5 VARIANTS="apache cli fpm" NODE_VERSIONS="22 24 26" ./tests-suite/run_tests.sh ``` The variables of [`tests-suite/config`](../tests-suite/config) select the images to test, e.g. `TAG_PREFIX` (images @@ -64,7 +66,7 @@ groups of the maintained PHP versions) are built and tested by the `legacy-v5.ym ## Adding a PHP or NodeJS version -- `utils/README.blueprint.md`: the version lists of the "Images" section +- `utils/README.blueprint.md` and `utils/images.blueprint.md`: the lists of versions - `utils/docker-bake.blueprint.hcl`: the build targets - `.github/workflows/workflow.yml` (maintained versions) or `.github/workflows/legacy-v5.yml` (non-maintained versions): the CI matrix diff --git a/docs/debugging/index.html b/docs/debugging/index.html index 1bcf7d2..f1ebe8f 100644 --- a/docs/debugging/index.html +++ b/docs/debugging/index.html @@ -1,13 +1,16 @@ --- layout: default title: Debugging, profiling, coverage +title_fr: Debugging, profiling, coverage +bilingual: true wide: true description: Start from your needs in development, CI and production, get the fewest tools that cover them, and a ready-to-use configuration for your IDE, your CI and your AI agent. +description_fr: Partez de vos besoins en développement, en CI et en production, obtenez le moins d'outils qui les couvrent, et une configuration prête à l'emploi pour votre IDE, votre CI et votre agent IA. --- -
-

Debugging, profiling, coverageDébogage, profilage, couverture

+

Debugging, profiling, coverageDebugging, profiling, coverage

Tell your needs: the page picks the fewest tools of the fat images, then gives the configuration of your IDE, your AI agent and each environment.

Indiquez vos besoins : la page choisit le moins d'outils possible parmi ceux des images fat, @@ -252,9 +252,9 @@

4Configuration4Configuration4Configuration4Configuration4Configuration4Configuration4Configuration4Configuration ``).join('') + ''; const cleanDir = (v) => String(v || '').trim().replace(/^\.\/+/, '').replace(/\/+$/, '').replace(/[^\w./-]/g, '') || '.'; -const IMAGE = (variant) => 'thecodingmachine/php:8.4-v5-' + variant; +const IMAGE = (variant) => 'thecodingmachine/php:8.6-v5-' + variant; const web = () => ctx.variant !== 'cli'; const sub = () => (ctx.dir === '.' ? '' : '/' + ctx.dir); const hostDir = () => (ctx.dir === '.' ? '.' : './' + ctx.dir); @@ -573,17 +573,17 @@

4Configuration`) + box(T('IDE', 'IDE'), chips('ide'), null, true) + box(T('AI agent', 'Agent IA'), chips('agent'), null, true); - const d = hostDir(), rows = [[d, '⇄', '/var/www/html', T('the same mapping in the IDE, for the breakpoints', "la même association dans l'IDE, pour les points d'arrêt")]]; + const d = hostDir(), rows = [[d, '⇄', '/var/www/html', T('the same mapping in the IDE, for the breakpoints', "le même mapping dans l'IDE, pour les breakpoints")]]; const w = Math.max(...rows.map(r => r[0].length)) + 2; $('machine-notes').innerHTML = `
${rows.map(([l, s, r, t]) => esc(l.padEnd(w)) + s + ' ' + esc(r.padEnd(24)) + c(t, '')).join('\n')}
`; } // ---------------------------------------------------------------- 4. Your IDE const IDE_DESC = { - phpstorm: T('The settings are stored in .idea/: commit it to share them.', 'Les réglages sont rangés dans .idea/ : versionnez-le pour les partager.'), + phpstorm: T('The settings are stored in .idea/: commit it to share them.', 'Les paramètres sont rangés dans .idea/ : versionnez-le pour les partager.'), vscode: T('With the PHP Debug extension.', "Avec l'extension PHP Debug."), devcontainer: T('VS Code reopens the project inside the app container: no path mapping, Xdebug connects to 127.0.0.1.', - "VS Code rouvre le projet dans le conteneur app : pas d'association de chemins, Xdebug se connecte à 127.0.0.1."), + "VS Code rouvre le projet dans le conteneur app : pas de path mapping, Xdebug se connecte à 127.0.0.1."), other: T('Any IDE that speaks DBGp.', 'Tout IDE qui parle DBGp.'), }; const PS_SERVER_ID = '3c5e2f0a-6b1d-4e8a-9f27-0d4b8a1c7e55', PS_INTERP_ID = '9a7d4c1e-2f3b-4a5c-8d6e-1b0f3e2a4c77'; @@ -598,7 +598,7 @@

4Configuration`, ' ', ` `, ' ', ' ', ' ', ' '); if (cov) l.push(' ' + cx(T('Tests and coverage: PHP of the running app service; DOCKER_ACCOUNT_NAME is the name of your Docker connection in Settings › Build, Execution, Deployment › Docker', - "Tests et couverture : le PHP du service app démarré ; DOCKER_ACCOUNT_NAME est le nom de votre connexion Docker dans Settings › Build, Execution, Deployment › Docker")), + "Tests et coverage : le PHP du service app démarré ; DOCKER_ACCOUNT_NAME est le nom de votre connexion Docker dans Settings › Build, Execution, Deployment › Docker")), ' ', ' ', ` `, ' ', @@ -609,7 +609,7 @@

4Configuration'); out.push(block('.idea/php.xml', T('add these components', 'ajoutez ces composants'), code(l))); - if (cov) out.push(block('.run/Tests.run.xml', T('Run › Tests, with coverage', 'Run › Tests, avec couverture'), code([ + if (cov) out.push(block('.run/Tests.run.xml', T('Run › Tests, with coverage', 'Run › Tests, avec coverage'), code([ '', ' ', ' ', ' ', @@ -634,8 +634,8 @@

4Configuration4Configuration.idea/php.xml: create the file if it is missing, otherwise replace the components of the same name. Copy .run/Tests.run.xml as is.', 'PhpStorm fermé, ajoutez les composants ci-dessus à .idea/php.xml : créez le fichier s\'il manque, sinon remplacez les composants de même nom. Copiez .run/Tests.run.xml tel quel.'), ui && x && T(`Settings › PHP › Servers, +: name app (the serverName of PHP_IDE_CONFIG), host localhost, port 80, debugger Xdebug. Check Use path mappings and, in front of ${d}, type /var/www/html.`, - `Settings › PHP › Servers, + : nom app (le serverName de PHP_IDE_CONFIG), hôte localhost, port 80, débogueur Xdebug. Cochez Use path mappings et, en face de ${d}, saisissez /var/www/html.`), + `Settings › PHP › Servers, + : nom app (le serverName de PHP_IDE_CONFIG), hôte localhost, port 80, debugger Xdebug. Cochez Use path mappings et, en face de ${d}, saisissez /var/www/html.`), ui && cov && T('Settings › PHP, CLI Interpreter › …, + › From Docker, Vagrant, VM, WSL, Remote…: Docker Compose, file compose.yaml, service app. Then Lifecycle: Connect to existing container. Name it app.', 'Settings › PHP, CLI Interpreter › …, + › From Docker, Vagrant, VM, WSL, Remote… : Docker Compose, fichier compose.yaml, service app. Puis Lifecycle : Connect to existing container. Nommez-le app.'), ui && cov && T('Settings › PHP › Test Frameworks, + › PHPUnit by Remote Interpreter: app, autoloader /var/www/html/vendor/autoload.php.', @@ -664,7 +664,7 @@

4ConfigurationRun › Edit Configurations, + › PHPUnit, nommée Tests : Defined in the configuration file, et dans les variables d'environnement ${covEnv(cov).map(([k, v]) => k + '=' + v).join(';')}.`), fw, cov && !ui && T('Settings › PHP: choose the CLI interpreter app (a setting of each developer).', - 'Settings › PHP : choisissez l\'interpréteur CLI app (un réglage propre à chaque développeur).')])); + 'Settings › PHP : choisissez l\'interpréteur CLI app (un paramètre propre à chaque développeur).')])); } else if (ctx.ide === 'vscode' || ctx.ide === 'devcontainer') { const inside = ctx.ide === 'devcontainer'; if (!ui) files.push(...vscodeFiles(inside)); @@ -678,7 +678,7 @@

4ConfigurationPHP Debug (Xdebug)', cov && 'Coverage Gutters'].filter(Boolean).join(' et ')}${inside ? ', puis clic droit › Add to devcontainer.json' : ''}.`), ui && x && (inside ? T('Run and Debug › create a launch.json file › PHP: keep Listen for Xdebug.', 'Run and Debug › create a launch.json file › PHP : gardez Listen for Xdebug.') : T(`Run and Debug › create a launch.json file › PHP. VS Code has no menu for the path mappings: in Listen for Xdebug, add "pathMappings": { "/var/www/html": "\${workspaceFolder}${sub()}" }.`, - `Run and Debug › create a launch.json file › PHP. VS Code n'a pas de menu pour l'association des chemins : dans Listen for Xdebug, ajoutez "pathMappings": { "/var/www/html": "\${workspaceFolder}${sub()}" }.`)), + `Run and Debug › create a launch.json file › PHP. VS Code n'a pas de menu pour le path mapping : dans Listen for Xdebug, ajoutez "pathMappings": { "/var/www/html": "\${workspaceFolder}${sub()}" }.`)), ui && cov && !inside && T(`Settings › Extensions › Coverage Gutters › Remote Path Resolve: ["/var/www/html", "${ctx.dir}"].`, `Settings › Extensions › Coverage Gutters › Remote Path Resolve : ["/var/www/html", "${ctx.dir}"].`), fw])); } else if (x) { @@ -694,7 +694,7 @@

4Configuration4ConfigurationAGENTS.md at the root of the repository: most agents read it (Cursor, Copilot, Gemini…).', 'Ajoutez cette section à AGENTS.md à la racine du dépôt : la plupart des agents le lisent (Cursor, Copilot, Gemini…).') - : T(`Copy the skill to the path above: ${AGENT_NAME()} loads it when you ask to debug, profile or measure the coverage.`, `Copiez le skill au chemin ci-dessus : ${AGENT_NAME()} le charge quand vous demandez de déboguer, profiler ou mesurer la couverture.`), + : T(`Copy the skill to the path above: ${AGENT_NAME()} loads it when you ask to debug, profile or measure the coverage.`, `Copiez le skill au chemin ci-dessus : ${AGENT_NAME()} le charge quand vous demandez de debugger, profiler ou mesurer le coverage.`), mcp && (ctx.agent === 'claude' ? T('Step debugging: in PhpStorm, Settings › Tools › MCP Server, enable it, then Auto-Configure for Claude Code. The agent then sets breakpoints and reads the variables.', 'Pas à pas : dans PhpStorm, Settings › Tools › MCP Server, activez-le, puis Auto-Configure pour Claude Code. L\'agent pose alors des points d\'arrêt et lit les variables.') : T('Step debugging: in PhpStorm, Settings › Tools › MCP Server, enable it and copy its configuration into your agent. The agent then sets breakpoints and reads the variables.', 'Pas à pas : dans PhpStorm, Settings › Tools › MCP Server, activez-le et copiez sa configuration dans votre agent. L\'agent pose alors des points d\'arrêt et lit les variables.')), @@ -723,7 +723,7 @@

4Configuration4Configuration4Configuration ' ' + l).join('\n') + '\n'; y += ' volumes:\n' + vol.join('\n') + '\n'; @@ -844,7 +844,7 @@

4Configuration ' ' + l).join('\n') + '\n steps:\n - uses: actions/checkout@v4\n - run: composer install\n - run: ' + covCmd + '\n' + - ' ' + c(T('Track the coverage between branches: send coverage.xml to Codecov or Coveralls', 'Suivre la couverture entre les branches : envoyez coverage.xml à Codecov ou Coveralls')) + '\n' + + ' ' + c(T('Track the coverage between branches: send coverage.xml to Codecov or Coveralls', 'Suivre le coverage entre les branches : envoyez coverage.xml à Codecov ou Coveralls')) + '\n' + ' - uses: actions/upload-artifact@v4\n with:\n name: coverage\n path: ' + P + 'coverage.xml\n'; } if (mem) { @@ -860,7 +860,7 @@

4Configuration ' ' + l).join('\n') + '\n script:\n' + (P ? ' - cd ' + ctx.dir + '\n' : '') + ' - composer install\n - ' + covCmd.replace('--coverage-clover coverage.xml', '--coverage-text --colors=never --coverage-cobertura coverage.xml') + '\n' + - ' ' + c(T('Shows the coverage in the merge requests, and its evolution between branches', "Affiche la couverture dans les merge requests, et son évolution entre les branches")) + '\n' + + ' ' + c(T('Shows the coverage in the merge requests, and its evolution between branches', "Affiche le coverage dans les merge requests, et son évolution entre les branches")) + '\n' + " coverage: '/^\\s*Lines:\\s*\\d+.\\d+\\%/'\n artifacts:\n reports:\n coverage_report:\n coverage_format: cobertura\n path: " + P + "coverage.xml\n"; } if (mem) { @@ -875,22 +875,22 @@

4Configuration o !== prof && (o.covers.includes('time') || o.covers.includes('mem')))[0]; if (prof && prof.tool === 'Blackfire') { y += c(T('Blackfire probe; the agent runs next to the application', "Sonde Blackfire ; l'agent tourne à côté de l'application")) + '\nENV PHP_EXTENSION_BLACKFIRE=1\n'; y += c(T('BLACKFIRE_AGENT: host name of the agent, at runtime', "BLACKFIRE_AGENT : nom d'hôte de l'agent, à l'exécution")) + '\n\n'; } else if (prof) { - y += c(T(`Profiling with ${prof.tool}`, `Profilage avec ${prof.tool}`)) + `\nENV PHP_PROFILER=${prof.tool.toLowerCase()}\n`; + y += c(T(`Profiling with ${prof.tool}`, `Profiling avec ${prof.tool}`)) + `\nENV PHP_PROFILER=${prof.tool.toLowerCase()}\n`; if (prof.level === 'a') { - y += c(T('Continuous profiling: 1% of the requests; raise it during an investigation', "Profilage continu : 1 % des requêtes ; augmentez-le le temps d'une enquête")) + '\nENV PHP_PROFILER_TRIGGER=sample\nENV PHP_PROFILER_SAMPLE_RATE=0.01\n'; + y += c(T('Continuous profiling: 1% of the requests; raise it during an investigation', "Profiling continu : 1 % des requêtes ; augmentez-le le temps d'une enquête")) + '\nENV PHP_PROFILER_TRIGGER=sample\nENV PHP_PROFILER_SAMPLE_RATE=0.01\n'; } else { - y += c(T('Only the requests carrying the secret trigger; the secret is set at runtime, never in the image', "Seulement les requêtes qui portent le déclencheur secret ; le secret est fourni à l'exécution, jamais dans l'image")) + '\n' + + y += c(T('Only the requests carrying the secret trigger; the secret is set at runtime, never in the image', "Seulement les requêtes qui portent le trigger secret ; le secret est fourni à l'exécution, jamais dans l'image")) + '\n' + c(T('PHP_PROFILER_TRIGGER_VALUE=', 'PHP_PROFILER_TRIGGER_VALUE=')) + '\n'; } if (second) y += c(T(`Memory and calls: during an investigation, redeploy with PHP_PROFILER=${second.tool.toLowerCase()}`, `Mémoire et appels : le temps d'une enquête, redéployez avec PHP_PROFILER=${second.tool.toLowerCase()}`)) + '\n'; - y += c(T('Where the profiles go: mount a volume on /tmp/php-profiles, or set PHP_PROFILER_OUTPUT_DIR', 'Où vont les profils : montez un volume sur /tmp/php-profiles, ou réglez PHP_PROFILER_OUTPUT_DIR')) + '\n\n'; + y += c(T('Where the profiles go: mount a volume on /tmp/php-profiles, or set PHP_PROFILER_OUTPUT_DIR', 'Où vont les profils : montez un volume sur /tmp/php-profiles, ou définissez PHP_PROFILER_OUTPUT_DIR')) + '\n\n'; } const o = toolFor('live', 'traces'); if (o) { @@ -905,11 +905,11 @@

4Configuration`', 'Profiler une page : `curl -H "X-PHP-Profile: 1" http://localhost/`')), '- ' + L(T('Profile a command: `docker compose exec app php-profile `', 'Profiler une commande : `docker compose exec app php-profile `')), '- ' + L(T('Read `' + prefix() + 'var/profiles/.summary.txt` first; grep the `.collapsed` file of the same profile for the full call stacks.', 'Lire d\'abord `' + prefix() + 'var/profiles/.summary.txt` ; chercher dans le fichier `.collapsed` du même profil pour les piles d\'appels complètes.')), ''); @@ -917,12 +917,12 @@

4Configuration` prints the flat profile of SPX.', 'Profiler une commande : `docker compose exec app php-profile ` affiche le profil à plat de SPX.')), ''); if (p && p.tool === 'Blackfire') l.push('- ' + L(T('Profile a command: `docker compose exec app blackfire run php `', 'Profiler une commande : `docker compose exec app blackfire run php `')), ''); const cov = toolFor('dev', 'cov'); - if (cov) l.push('- ' + L(T('Coverage', 'Couverture')) + ': `docker compose run --rm ' + (cov.tool === 'PCOV' ? '-e PHP_EXTENSION_PCOV=1' : '-e PHP_EXTENSION_XDEBUG=1 -e XDEBUG_MODE=coverage') + ' app vendor/bin/phpunit --coverage-text`'); + if (cov) l.push('- ' + L(T('Coverage', 'Coverage')) + ': `docker compose run --rm ' + (cov.tool === 'PCOV' ? '-e PHP_EXTENSION_PCOV=1' : '-e PHP_EXTENSION_XDEBUG=1 -e XDEBUG_MODE=coverage') + ' app vendor/bin/phpunit --coverage-text`'); if (toolFor('dev', 'traces')) l.push('- ' + L(T('Traces: `curl "http://localhost:16686/api/traces?service=app&limit=20"`', 'Traces : `curl "http://localhost:16686/api/traces?service=app&limit=20"`'))); if (toolFor('dev', 'step')) l.push('- ' + L(ctx.ide === 'phpstorm' ? T('Step debugging: use the Xdebug tools of the PhpStorm MCP server; a session starts with `XDEBUG_TRIGGER=1` (cookie, or `-e XDEBUG_TRIGGER=1` on `docker compose exec`). Ask the user to start listening in PhpStorm first.', "Pas à pas : utiliser les outils Xdebug du serveur MCP de PhpStorm ; une session démarre avec `XDEBUG_TRIGGER=1` (cookie, ou `-e XDEBUG_TRIGGER=1` sur `docker compose exec`). Demander d'abord à l'utilisateur de lancer l'écoute dans PhpStorm.") - : T('Step debugging: ask the user to start listening in the IDE, then trigger the session with `XDEBUG_TRIGGER=1`.', "Pas à pas : demander à l'utilisateur de lancer l'écoute dans l'IDE, puis déclencher la session avec `XDEBUG_TRIGGER=1`."))); + : T('Step debugging: ask the user to start listening in the IDE, then trigger the session with `XDEBUG_TRIGGER=1`.', "Pas à pas : demander à l'utilisateur de lancer l'écoute dans l'IDE, puis lancer la session avec `XDEBUG_TRIGGER=1`."))); return l.join('\n') + '\n'; } @@ -948,8 +948,8 @@

4Configuration4Configuration4ConfigurationStart Listening for PHP Debug Connections in the toolbar.', 'Start Listening for PHP Debug Connections dans la barre d\'outils.'), trig, - cov && T('Run › Tests with coverage: the covered lines show in the editor.', 'Run › Tests avec couverture : les lignes couvertes s\'affichent dans l\'éditeur.')]; + cov && T('Run › Tests with coverage: the covered lines show in the editor.', 'Run › Tests avec coverage : les lignes couvertes s\'affichent dans l\'éditeur.')]; } else if (ctx.ide === 'vscode' || ctx.ide === 'devcontainer') { name = 'VS Code'; const run = ctx.ide === 'devcontainer' @@ -1010,9 +1010,9 @@

4Configuration: server of PhpStorm holding the path mappings', 'serverName= : serveur PhpStorm qui porte la correspondance des chemins')], ['PHP_EXTENSION_PCOV', '0', 'PCOV', T('Loads PCOV', 'Charge PCOV')], ['PHP_INI_PCOV__DIRECTORY', 'src, lib, app', 'PCOV', T('Directory measured by PCOV', 'Répertoire mesuré par PCOV')], - ['PHP_PROFILER', '', 'Excimer XHProf SPX Xdebug', T('excimer, xhprof, spx or xdebug: loads the profiler; php-profile profiles a command', "excimer, xhprof, spx ou xdebug : charge le profileur ; php-profile profile une commande")], - ['PHP_PROFILER_TRIGGER', 'request', 'Excimer XHProf Xdebug', T('request: on a trigger (X-PHP-Profile header, PHP_PROFILE cookie or GET parameter, PHP_PROFILE variable of a command; XDEBUG_TRIGGER with Xdebug); always: everything; sample: a share of the requests (Excimer, XHProf)', 'request : sur déclencheur (en-tête X-PHP-Profile, cookie ou paramètre GET PHP_PROFILE, variable PHP_PROFILE d\'une commande ; XDEBUG_TRIGGER avec Xdebug) ; always : tout ; sample : une part des requêtes (Excimer, XHProf)')], - ['PHP_PROFILER_TRIGGER_VALUE', '', 'Excimer XHProf Xdebug', T('Secret value expected in the trigger', 'Valeur secrète attendue dans le déclencheur')], + ['PHP_PROFILER', '', 'Excimer XHProf SPX Xdebug', T('excimer, xhprof, spx or xdebug: loads the profiler; php-profile profiles a command', "excimer, xhprof, spx ou xdebug : charge le profiler ; php-profile profile une commande")], + ['PHP_PROFILER_TRIGGER', 'request', 'Excimer XHProf Xdebug', T('request: on a trigger (X-PHP-Profile header, PHP_PROFILE cookie or GET parameter, PHP_PROFILE variable of a command; XDEBUG_TRIGGER with Xdebug); always: everything; sample: a share of the requests (Excimer, XHProf)', 'request : sur trigger (header X-PHP-Profile, cookie ou paramètre GET PHP_PROFILE, variable PHP_PROFILE d\'une commande ; XDEBUG_TRIGGER avec Xdebug) ; always : tout ; sample : une part des requêtes (Excimer, XHProf)')], + ['PHP_PROFILER_TRIGGER_VALUE', '', 'Excimer XHProf Xdebug', T('Secret value expected in the trigger', 'Valeur secrète attendue dans le trigger')], ['PHP_PROFILER_SAMPLE_RATE', '0.01', 'Excimer XHProf', T('Share of the requests profiled with sample', 'Part des requêtes profilées avec sample')], ['PHP_PROFILER_OUTPUT_DIR', '/tmp/php-profiles', 'Excimer XHProf Xdebug', T('Where the profiles are written', 'Où les profils sont écrits')], ['PHP_PROFILER_EXCIMER_PERIOD', '0.001', 'Excimer', T('Sampling interval of Excimer, in seconds', "Intervalle d'échantillonnage d'Excimer, en secondes")], @@ -1020,7 +1020,7 @@

4Configuration4Configuration${L(T('Variables', 'Variables'))} $request = Request {method: "POST", …} $this->carts = CartRepository {…} -${L(T('Call stack', "Pile d'appels"))} +${L(T('Call stack', 'Call stack'))} CartController->add() CartController.php:43 HttpKernel->handle() HttpKernel.php:181`, PCOV: () => `
$ vendor/bin/phpunit --coverage-text
@@ -1096,12 +1096,12 @@ 

4Configuration `
${SHOTS[tool]()}
`; const INFO = { - Xdebug: { what: T('Step debugger: stops on a breakpoint and shows the variables and the call stack in the IDE. Also measures the coverage of the branches.', "Débogueur pas à pas : s'arrête sur un point d'arrêt et montre les variables et la pile d'appels dans l'IDE. Mesure aussi la couverture des branches."), }, - PCOV: { what: T('Coverage of the lines run by the tests, for PHPUnit reports.', 'Couverture des lignes exécutées par les tests, pour les rapports PHPUnit.'), }, - Excimer: { what: T('Sampling profiler: looks at the stack every millisecond, which gives where the time goes.', 'Profileur par échantillonnage : regarde la pile toutes les millisecondes, ce qui donne où part le temps.'), }, + Xdebug: { what: T('Step debugger: stops on a breakpoint and shows the variables and the call stack in the IDE. Also measures the coverage of the branches.', "Debugger pas à pas : s'arrête sur un breakpoint et montre les variables et la call stack dans l'IDE. Mesure aussi le coverage des branches."), }, + PCOV: { what: T('Coverage of the lines run by the tests, for PHPUnit reports.', 'Coverage des lignes exécutées par les tests, pour les rapports PHPUnit.'), }, + Excimer: { what: T('Sampling profiler: looks at the stack every millisecond, which gives where the time goes.', 'Profiler par échantillonnage : regarde la stack toutes les millisecondes, ce qui donne où part le temps.'), }, XHProf: { what: T('Records every function call: exact call counts, time and memory.', "Enregistre chaque appel de fonction : nombre d'appels, temps et mémoire exacts."), }, SPX: { what: T('Records every function call and shows it in its own web UI, with a timeline.', "Enregistre chaque appel de fonction et l'affiche dans sa propre interface web, avec une timeline."), }, - Blackfire: { what: T('Hosted profiling service: call graph, comparison of two profiles, performance assertions in the CI, monitoring.', "Service de profilage hébergé : graphe d'appels, comparaison de deux profils, assertions de performance en CI, monitoring."), proprietary: true }, + Blackfire: { what: T('Hosted profiling service: call graph, comparison of two profiles, performance assertions in the CI, monitoring.', "Service de profiling hébergé : call graph, comparaison de deux profils, assertions de performance en CI, monitoring."), proprietary: true }, OpenTelemetry: { what: T('Traces the requests across your services: duration, SQL queries, HTTP calls. No detail per PHP function.', 'Trace les requêtes à travers vos services : durée, requêtes SQL, appels HTTP. Aucun détail par fonction PHP.'), }, }; // Inside a tool card: what it does, its strengths and limits, how an agent uses it, and an example screen @@ -1115,8 +1115,7 @@

4Configuration4Configuration b.classList.toggle('on', b.dataset.v === lang)); // The plans of the CI and the live environments first: development reuses their tools when it can reuse = new Set(); const ci = plan('ci'), live = plan('live'); @@ -1172,7 +1170,6 @@

4Configuration { const v = e.target.dataset.v; if (v) { lang = v; render(); } }; $('needs').onclick = (e) => { const v = e.target.dataset.f, seg = e.target.closest('.seg'); if (v && seg && !e.target.getAttribute('aria-disabled')) { freq[seg.dataset.k] = v; keepPlace(seg, () => document.querySelector(`.seg[data-k="${seg.dataset.k}"]`)); } diff --git a/docs/extensions.md b/docs/extensions.md index 8397a35..48c143f 100644 --- a/docs/extensions.md +++ b/docs/extensions.md @@ -14,7 +14,7 @@ These extensions are enabled by default in the slim images: `calendar` `ctype` ` `Reflection` `session` `shmop` `SimpleXML` `sockets` `sodium` `SPL` `sysvmsg` `sysvsem` `sysvshm` `tokenizer` `xml` `xmlreader` `xmlwriter` `xsl` `zip` -This list can be outdated, you can verify it with: `docker run --rm thecodingmachine/php:8.4-v5-slim-cli php -m` +This list can be outdated, you can verify it with: `docker run --rm thecodingmachine/php:8.6-v5-slim-cli php -m` ## Extensions of the fat images @@ -27,7 +27,7 @@ This list can be outdated, you can verify it with: `docker run --rm thecodingmac `pdo_odbc` `pdo_pgsql` `pdo_sqlite` `pgsql` `pspell` `rdkafka` `shmop` `snmp` `sockets` `spx` `sqlite3` `swoole` `tidy` `uploadprogress` `uuid` `xdebug` `xhprof` `xmlrpc` `xsl` `yaml` `zstd` -This list can be outdated, you can verify it with: `docker run --rm thecodingmachine/php:8.4-v5-cli php -m` +This list can be outdated, you can verify it with: `docker run --rm thecodingmachine/php:8.6-v5-cli php -m` **Notes:** @@ -49,7 +49,7 @@ Use the `PHP_EXTENSION_` environment variables: ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache environment: # Enable the PostgreSQL extension PHP_EXTENSION_PGSQL: 1 @@ -69,7 +69,7 @@ With a slim image, the `PHP_EXTENSIONS` ARG lists the extensions to install duri ```Dockerfile ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql redis soap" -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache # The build automatically downloads and compiles the extensions # (thanks to an ONBUILD hook in the slim image) ``` @@ -85,7 +85,7 @@ Beware: # The PHP_EXTENSIONS ARG applies to the slim image ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql soap" -FROM thecodingmachine/php:8.4-v5-apache-node24 AS builder +FROM thecodingmachine/php:8.6-v5-apache-node24 AS builder COPY --chown=docker:docker sources/web . RUN composer install &&\ @@ -93,7 +93,7 @@ RUN composer install &&\ yarn build # The slim image builds the extensions listed at the very top of the file -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ENV APP_ENV=prod \ APACHE_DOCUMENT_ROOT=public/ diff --git a/docs/fpm.md b/docs/fpm.md index 34df41b..90eb263 100644 --- a/docs/fpm.md +++ b/docs/fpm.md @@ -9,13 +9,13 @@ not HTTP. To serve your application over HTTP, you need a web server in front of ## Built-in Apache ```bash -$ docker run -p 80:80 -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-fpm +$ docker run -p 80:80 -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm ``` ```yml services: app: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm ports: - "80:80" environment: @@ -64,7 +64,7 @@ files of the application. Example with nginx: ```yml services: php: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm volumes: - .:/var/www/html web: @@ -105,7 +105,7 @@ commands run with the owner of the working directory (see [Permissions](advanced ```yml services: app: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm working_dir: /var/www environment: PHP_FPM_WEB_SERVER: apache @@ -149,12 +149,12 @@ With the built-in Apache, send the requests of the back office to this pool: ```yml services: app: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm environment: PHP_FPM_WEB_SERVER: apache volumes: - .:/var/www/html - - ./admin-pool.conf:/etc/php/8.4/fpm/pool.d/admin.conf:ro + - ./admin-pool.conf:/etc/php/8.6/fpm/pool.d/admin.conf:ro - ./apache-admin-pool.conf:/etc/apache2/conf-enabled/admin-pool.conf:ro ``` @@ -215,8 +215,8 @@ error. Use the `PHP_INI_*` environment variables, or a [`.user.ini` file](https: ## Migrating from the apache variant -1. Use the *fpm* image and enable the built-in Apache: `thecodingmachine/php:8.4-v5-apache` becomes - `thecodingmachine/php:8.4-v5-fpm` with `PHP_FPM_WEB_SERVER=apache`. Keep your `APACHE_*` variables. +1. Use the *fpm* image and enable the built-in Apache: `thecodingmachine/php:8.6-v5-apache` becomes + `thecodingmachine/php:8.6-v5-fpm` with `PHP_FPM_WEB_SERVER=apache`. Keep your `APACHE_*` variables. 2. Set the number of PHP workers (`PHP_FPM_PM_MAX_CHILDREN`) for your traffic and your memory (see above, or the [tuning simulator](tuning/)). 3. Replace the `php_value` / `php_flag` directives of your `.htaccess` files. diff --git a/docs/fr/advanced.md b/docs/fr/advanced.md new file mode 100644 index 0000000..f8adb0d --- /dev/null +++ b/docs/fr/advanced.md @@ -0,0 +1,146 @@ +# Fonctions avancées + +## Permissions {#permissions} + +Les images limitent les problèmes de permissions de fichiers fréquents avec Docker. + +Les commandes d'un conteneur tournent habituellement en `root`, donc les fichiers qu'elles créent (par ex. avec +`composer install`) appartiennent à `root` sur votre machine. Le conteneur et la machine ne partagent pas leurs +utilisateurs : vous êtes peut-être connecté en `superdev` (ID 1000) sur votre machine alors que le conteneur n'a aucun +utilisateur d'ID 1000. + +Les images contiennent un utilisateur `docker`. Au démarrage, l'entrypoint regarde le propriétaire du répertoire de +travail (`/var/www/html` pour *apache* et *fpm*, `/usr/src/app` pour *cli*) et **change l'ID de l'utilisateur +`docker`** pour celui de ce propriétaire. Les commandes, Apache et PHP-FPM tournent alors sous `docker` : + +- votre application PHP peut modifier n'importe quel fichier de votre projet ; +- vous pouvez modifier n'importe quel fichier créé par le conteneur. + +
L’utilisateur docker prend l’UID du propriétaire du projet monté
+ +Si cet ID est déjà pris par un compte système de l'image (par ex. `998`, utilisé par `systemd-network` dans l'image +et souvent par l'utilisateur `gitlab-runner` sur les machines de CI), ce compte système est déplacé vers un autre ID : +les commandes sont toujours lancées par l'utilisateur `docker`. + +`DOCKER_USER` définit l'utilisateur explicitement, avec un nom d'utilisateur de l'image ou un ID : + +```bash +DOCKER_USER=1001 +``` + +**En production**, Apache ne devrait pas pouvoir modifier les fichiers PHP de votre application : si un attaquant peut +les changer par une faille de sécurité, il peut exécuter n'importe quel code PHP. Faites tourner Apache sous +`www-data` (voir [Utilisateur Apache](variants.md#apache-user)). + +## NodeJS {#nodejs} + +Les images fat ont des variantes NodeJS (par ex. `thecodingmachine/php:8.6-v5-apache-node24`), voir la +[liste des images](../../README.md#images). + +Avec une image slim, l'ARG `NODE_VERSION` installe NodeJS (avec npm et yarn) pendant le build : + +```Dockerfile +ARG NODE_VERSION=24 +FROM thecodingmachine/php:8.6-v5-slim-apache +``` + +L'instruction `ARG NODE_VERSION` doit être écrite avant le `FROM`. Ce n'est pas une faute de frappe. + +Les binaires de `node_modules/.bin` et de Composer (`vendor/bin`, binaires globaux) se lancent sans leur chemin, y +compris avec `docker exec` / `docker compose exec` (par ex. `docker compose exec app phpstan`). + +## Version de Composer {#composer-version} + +Les images sont livrées avec la dernière version de Composer. `COMPOSER_VERSION` en installe une autre : une version +exacte (par ex. `2.4.4`) ou un canal (`1`, `2`, ou `2.2` pour la version LTS). + +```bash +COMPOSER_VERSION=2.4.4 +``` + +La version est installée au démarrage du conteneur (il faut un accès réseau). Avec une image slim, installez-la +plutôt pendant le build, avec un ARG avant le `FROM` : + +```Dockerfile +ARG COMPOSER_VERSION=2.4.4 +FROM thecodingmachine/php:8.6-v5-slim-apache +``` + +## Locales {#locales} + +Seules les locales `C`, `C.UTF-8` et `POSIX` sont disponibles par défaut. `LOCALES` liste les locales à générer au +démarrage du conteneur : + +```bash +LOCALES=fr_FR.UTF-8 de_DE.UTF-8 +# Facultatif : la locale par défaut de l'extension intl +PHP_INI_INTL__DEFAULT_LOCALE=fr_FR.UTF-8 +``` + +Les outils de locales sont **installés par défaut dans les images fat**. Avec une image slim, installez-les avec un +ARG avant le `FROM` : + +```Dockerfile +ARG INSTALL_LOCALES=1 +FROM thecodingmachine/php:8.6-v5-slim-apache +``` + +## Clés privées SSH {#ssh-private-keys} + +Si votre projet dépend d'un [paquet stocké dans un dépôt Git privé](https://getcomposer.org/doc/05-repositories.md#using-private-repositories), +`composer install` a besoin de votre clé privée SSH. + +**En développement**, montez vos clés dans le conteneur : + +```yml +services: + my_app: + image: thecodingmachine/php:8.6-v5-apache + volumes: + - ~/.ssh:/home/docker/.ssh +``` + +**Dans un Dockerfile**, passez la clé et la signature du serveur (`ssh-keyscan myserver.com`) en arguments de build : + +```Dockerfile +FROM thecodingmachine/php:8.6-v5-apache + +ARG SSH_PRIVATE_KEY +ARG SSH_KNOWN_HOSTS + +RUN ssh-add <(echo "$SSH_PRIVATE_KEY") +RUN echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts +``` + +```bash +$ docker build -t my_image --build-arg SSH_PRIVATE_KEY="$SSH_PRIVATE_KEY" --build-arg SSH_KNOWN_HOSTS="$SSH_KNOWN_HOSTS" . +``` + +Attention : les arguments de build sont visibles dans l'historique de l'image. Préférez les +[secrets de build](https://docs.docker.com/build/building/secrets/) pour une image que vous distribuez. + +## Kubernetes {#kubernetes} + +L'entrypoint utilise `sudo` : l'utilisateur `docker` doit modifier la configuration de PHP en tant que `root`. Le +paramètre de sécurité Kubernetes `allowPrivilegeEscalation: false` interdit `sudo` et casse l'image, avec ce message dans +les logs : + +``` +sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the 'nosuid' option set or an NFS file system without root privileges? +``` + +Ne passez jamais cette option à `false` : + +```yml +apiVersion: v1 +kind: Pod +# ... +spec: + containers: + - name: foobar + image: thecodingmachine/php:8.6-v5-apache + securityContext: + allowPrivilegeEscalation: true # n'utilisez jamais "false" ici +``` + +Si votre cluster interdit d'écouter sur les ports inférieurs à 1024, voir [Ports d'Apache](variants.md#ports). diff --git a/docs/fr/contributing.md b/docs/fr/contributing.md new file mode 100644 index 0000000..7bfc040 --- /dev/null +++ b/docs/fr/contributing.md @@ -0,0 +1,78 @@ +--- +--- +# Contribuer + +Proposez vos pull requests sur la branche `v5` : les correctifs et les fonctionnalités arrivent d'abord en v5. Chaque +push sur `v5` reporte ses nouveaux commits sur `v6` par cherry-pick (`.github/workflows/forward-port.yml`), donc `v6` +contient les commits de la v5 plus les siens. Quand un commit entre en conflit avec `v6`, le workflow échoue : +reportez-le à la main avec `git cherry-pick -x`, résolvez, poussez sur `v6`, puis relancez le workflow. Seuls les +changements qui cassent la compatibilité de la v5 (nouvelles valeurs par défaut, fonctionnalités supprimées) vont +directement sur `v6`. + +## Fichiers générés {#generated-files} + +Les fichiers `Dockerfile.*`, `docker-bake.hcl` et `README.md` sont générés à partir des modèles du répertoire `utils` +avec [Orbit](https://github.com/gulien/orbit) : modifiez `utils/Dockerfile.*.blueprint`, +`utils/docker-bake.blueprint.hcl` ou `utils/README.blueprint.md`, puis lancez : + +```bash +$ make blueprint +``` + +Les pages du répertoire `docs` ne sont pas générées, sauf `images.md` (`utils/images.blueprint.md`) : modifiez-les directement. Chaque page en anglais a sa traduction +française dans `docs/fr/` (même nom de fichier), à mettre à jour avec elle ; les pages interactives (`tuning/`, +`reverse-proxy/`, `debugging/`) portent les deux langues dans le même fichier. + +Les images d'une version de PHP partagent leurs premières couches (voir `utils/docker-bake.blueprint.hcl`) : + +- `Dockerfile.base` : les couches communes à toutes les images ; +- `Dockerfile.slim.` : l'image *slim* de la variante, construite sur `Dockerfile.base` ; +- `Dockerfile.extensions` : les extensions, installées une seule fois pour les 3 variantes sur `Dockerfile.base` ; +- `Dockerfile.` : l'image *fat*, construite sur `Dockerfile.slim.` appliqué sur + `Dockerfile.extensions` ; +- `Dockerfile..node` : les images *node*, construites sur l'image *fat*. + +## Construire et tester {#building-and-testing} + +Les tests utilisent [bash_unit](https://github.com/pgrange/bash_unit) (voir la +[suite de tests](../../tests-suite/README.md), en anglais). Construire et tester une version de PHP (variantes *cli*, +*apache* et *fpm*) : + +```bash +$ make test-8.6 +``` + +`make test-quick` construit et teste la variante *cli* des versions de PHP maintenues, sans NodeJS. + +Pour tester des images déjà construites, lancez directement la suite de tests : + +```bash +$ PHP_VERSION=8.6 BRANCH=v5 VARIANT=apache ./tests-suite/bash_unit -f tap ./tests-suite/*.sh +``` + +Pour lancer en parallèle les fichiers de test de plusieurs variantes, comme le fait la CI (`TEST_JOBS` fichiers de +test en même temps, 2 par défaut, avec un log par fichier de test) : + +```bash +$ PHP_VERSION=8.6 BRANCH=v5 VARIANTS="apache cli fpm" NODE_VERSIONS="22 24 26" ./tests-suite/run_tests.sh +``` + +Les variables de [`tests-suite/config`](../../tests-suite/config) choisissent les images à tester, par ex. +`TAG_PREFIX` (images construites avec `TAG_PREFIX=mytest- docker buildx bake ...`) ou `PLATFORM` (par ex. +`linux/arm64` avec QEMU). + +**Apple Silicon :** le système de fichiers de macOS gère les utilisateurs et les permissions différemment : les tests +de permissions d'une image `linux/arm64` peuvent échouer sur un Mac, alors que les images fonctionnent normalement. +Lancez plutôt les tests dans une machine virtuelle `linux/arm64`. + +**Versions non maintenues :** PHP 7.4, 8.0 et 8.1 (toutes leurs images) et NodeJS 18 et 20 (groupes de bake +`-legacy-node` des versions de PHP maintenues) sont construits et testés par le workflow `legacy-v5.yml`, lancé à la +main. + +## Ajouter une version de PHP ou de NodeJS {#adding-a-php-or-nodejs-version} + +- `utils/README.blueprint.md` et `utils/images.blueprint.md` : les listes de versions +- `utils/docker-bake.blueprint.hcl` : les cibles de build +- `.github/workflows/workflow.yml` (versions maintenues) ou `.github/workflows/legacy-v5.yml` (versions non + maintenues) : la matrice de la CI +- `extensions/` : les extensions disponibles pour cette version de PHP diff --git a/docs/fr/extensions.md b/docs/fr/extensions.md new file mode 100644 index 0000000..a23d433 --- /dev/null +++ b/docs/fr/extensions.md @@ -0,0 +1,106 @@ +# Extensions PHP + +Les images existent en 2 *types* : + +- les images **slim** ne contiennent que les extensions de base : vous les utiliserez typiquement dans un `Dockerfile` + qui compile les extensions dont votre application a besoin ; +- les images **fat** contiennent les extensions les plus utilisées, prêtes à être activées par des variables + d'environnement : vous les utiliserez typiquement en local ou en CI. + +## Extensions des images slim {#extensions-of-the-slim-images} + +Ces extensions sont activées par défaut dans les images slim : `calendar` `ctype` `curl` `date` `dom` `exif` `fileinfo` +`filter` `ftp` `gettext` `iconv` `json` `mbstring` `opcache` `openssl` `pcntl` `pcre` `PDO` `Phar` `posix` `readline` +`Reflection` `session` `shmop` `SimpleXML` `sockets` `sodium` `SPL` `sysvmsg` `sysvsem` `sysvshm` `tokenizer` `xml` +`xmlreader` `xmlwriter` `xsl` `zip` + +Cette liste peut être obsolète, vous pouvez la vérifier avec : `docker run --rm thecodingmachine/php:8.6-v5-slim-cli php -m` + +## Extensions des images fat {#extensions-of-the-fat-images} + +**Activées par défaut (en plus des extensions des images slim) :** `apcu` `hash` `iconv` `igbinary` `mysqli` +`mysqlnd` `pdo_mysql` `redis` `soap` `xsl` `zlib` + +**Disponibles (activables par variables d'environnement) :** `amqp` `ast` `bcmath` `blackfire` `bz2` `dba` `decimal` +`ds` `enchant` `exif` `excimer` `ffi` `mailparse` `msgpack` `gd` `gettext` `gmp` `gnupg` `grpc` `igbinary` `imagick` +`imap` `inotify` `intl` `ldap` `lz4` `mcrypt` `memcached` `mongodb` `odbc` `opentelemetry` `pcov` `pdo_dblib` +`pdo_odbc` `pdo_pgsql` `pdo_sqlite` `pgsql` `pspell` `rdkafka` `shmop` `snmp` `sockets` `spx` `sqlite3` `swoole` `tidy` +`uploadprogress` `uuid` `xdebug` `xhprof` `xmlrpc` `xsl` `yaml` `zstd` + +Cette liste peut être obsolète, vous pouvez la vérifier avec : `docker run --rm thecodingmachine/php:8.6-v5-cli php -m` + +**Remarques :** + +- *ev* n'est pas disponible en PHP 8.1+ +- *swoole* n'est pas disponible en PHP 8.6 : swoole ne le prend pas encore en charge +- *spx* n'est pas disponible en PHP 8.6 : SPX ne le prend pas encore en charge +- *mcrypt* est obsolète et son usage est déconseillé : elle n'est fournie que pour les applications anciennes +- *imagick* prend en charge les images SVG, WMF, DjVu et OpenEXR en plus des formats courants. Si vous traitez des + images non fiables, vous pouvez restreindre les formats autorisés dans la politique d'ImageMagick + (`/etc/ImageMagick-6/policy.xml`) +- Les extensions dont dépend une extension activée sont activées avec elle, même si elles sont désactivées : `igbinary` + et `msgpack` pour *memcached*, `igbinary` pour *redis*, `mbstring` pour *mailparse*, `curl` et `mysqlnd` pour + *swoole*, `mysqlnd` pour *mysqli* et *pdo_mysql* +- Pour debugger, profiler ou mesurer le coverage (*xdebug*, *pcov*, *excimer*, *xhprof*, *spx*, *blackfire*, *opentelemetry*), voir [Debugging, profiling, coverage](../debugging/#lang=fr) + +## Activer et désactiver des extensions dans les images fat {#enablingdisabling-extensions-in-the-fat-images} + +Utilisez les variables d'environnement `PHP_EXTENSION_` : + +```yml +services: + my_app: + image: thecodingmachine/php:8.6-v5-apache + environment: + # Active l'extension PostgreSQL + PHP_EXTENSION_PGSQL: 1 + # Désactive l'extension Mysqli (activée par défaut) + PHP_EXTENSION_MYSQLI: 0 +``` + +Autre possibilité, la variable `PHP_EXTENSIONS` liste les extensions à activer : + +```bash +PHP_EXTENSIONS=pgsql gettext imap +``` + +## Compiler des extensions dans les images slim {#compiling-extensions-in-the-slim-images} + +Avec une image slim, l'ARG `PHP_EXTENSIONS` liste les extensions à installer pendant le build : + +```Dockerfile +ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql redis soap" +FROM thecodingmachine/php:8.6-v5-slim-apache +# Le build télécharge et compile automatiquement les extensions +# (grâce à un hook ONBUILD de l'image slim) +``` + +Attention : + +- L'instruction `ARG PHP_EXTENSIONS` doit être écrite avant le `FROM`. Ce n'est pas une faute de frappe. +- `ARG PHP_EXTENSIONS=""` n'est pas la même chose que `ENV PHP_EXTENSIONS=""`. +- `ARG PHP_EXTENSION_` (comme les variables d'environnement des images fat) n'est pas pris en charge. +- Avec un build multi-stage, l'`ARG` doit être tout en haut du fichier (avant le premier `FROM`) : + +```Dockerfile +# L'ARG PHP_EXTENSIONS s'applique à l'image slim +ARG PHP_EXTENSIONS="apcu mysqli pdo_mysql soap" + +FROM thecodingmachine/php:8.6-v5-apache-node24 AS builder + +COPY --chown=docker:docker sources/web . +RUN composer install &&\ + yarn install &&\ + yarn build + +# L'image slim compile les extensions listées tout en haut du fichier +FROM thecodingmachine/php:8.6-v5-slim-apache + +ENV APP_ENV=prod \ + APACHE_DOCUMENT_ROOT=public/ + +COPY --from=builder /var/www/html . +``` + +Dans cet exemple, l'image fat lance le `yarn build`, et le résultat est copié dans une image slim qui ne contient pas +NodeJS et ne contient que les extensions nécessaires. diff --git a/docs/fr/fpm.md b/docs/fr/fpm.md new file mode 100644 index 0000000..cccad20 --- /dev/null +++ b/docs/fr/fpm.md @@ -0,0 +1,227 @@ +# Exécuter une application PHP avec la variante fpm + +La variante *fpm* fait tourner [PHP-FPM](https://www.php.net/manual/fr/install.fpm.php), qui parle FastCGI (port +`9000`), pas HTTP. Pour exposer votre application en HTTP, il faut un serveur web devant : + +- l'**Apache intégré** de l'image (`PHP_FPM_WEB_SERVER=apache`) : un seul conteneur, aucune configuration de serveur web ; +- ou **votre propre serveur web** (nginx, Caddy, Traefik…) dans un autre conteneur. + +## Apache intégré {#built-in-apache} + +```bash +$ docker run -p 80:80 -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm +``` + +```yml +services: + app: + image: thecodingmachine/php:8.6-v5-fpm + ports: + - "80:80" + environment: + PHP_FPM_WEB_SERVER: apache + APACHE_DOCUMENT_ROOT: public/ + PHP_FPM_PM_MAX_CHILDREN: 20 + volumes: + - .:/var/www/html + healthcheck: + test: ["CMD", "php-fpm-healthcheck"] +``` + +Apache tourne avec le MPM `mpm_event` et envoie les requêtes PHP à PHP-FPM, dans le même conteneur. Les paramètres +Apache de la variante *apache* sont disponibles : fichiers `.htaccess`, `APACHE_DOCUMENT_ROOT`, `APACHE_EXTENSION_*` +et `APACHE_EXTENSIONS` (voir [Variantes](variants.md#apache)). +`mpm_event`, `proxy` et `proxy_fcgi` sont activés à la place de `mpm_prefork` et `mod_php`. + +Si Apache ou PHP-FPM s'arrête, l'autre est arrêté aussi et le conteneur sort en erreur, pour que votre orchestrateur +le redémarre. Sur `docker stop`, les deux s'arrêtent proprement : les requêtes en cours se terminent. + +### Avantages sur la variante apache {#advantages-over-the-apache-variant} + +Avec `mod_php` (la variante *apache*), Apache doit utiliser `mpm_prefork` : chaque connexion occupe un processus +Apache entier qui embarque PHP, y compris les connexions keep-alive inactives (un navigateur en ouvre jusqu'à 6) et +les fichiers statiques. Avec PHP-FPM, Apache garde les connexions avec quelques threads, et seules les requêtes PHP +atteignent les workers PHP. + +Les deux atteignent la même capacité, limitée par le CPU, quand rien n'occupe les connexions (clients rapides, ou un +reverse proxy devant le conteneur). Dès que les connexions vivent plus longtemps que les requêtes PHP, la variante +*fpm* sert davantage ([benchmark](../../benchmarks/capacity/README.md), 1 CPU) : **+63 % avec HTTPS** terminé dans le +conteneur (keep-alive et HTTP/2), et **+16 % à +29 % de pages servies pendant un pic de trafic** derrière un reverse +proxy, sans le risque de manquer de mémoire avec de nombreux processus mod_php. + +Autres différences : + +- le nombre de workers PHP se règle indépendamment du nombre de connexions (voir plus bas) ; +- HTTP/2 peut être activé (`APACHE_EXTENSION_HTTP2=1`) : il n'est pas servi avec `mpm_prefork` ; +- [`fastcgi_finish_request()`](https://www.php.net/manual/fr/function.fastcgi-finish-request.php) est disponible : la + réponse part vers le client, et le script peut continuer avec des tâches plus lentes. + +## Votre propre serveur web {#your-own-web-server} + +PHP-FPM écoute sur le port `9000` du conteneur. Le serveur web doit lui envoyer les requêtes PHP, avec le chemin du +script **dans le conteneur PHP** (`SCRIPT_FILENAME`), et servir lui-même les fichiers statiques : les deux conteneurs +ont besoin des fichiers de l'application. Exemple avec nginx : + +```yml +services: + php: + image: thecodingmachine/php:8.6-v5-fpm + volumes: + - .:/var/www/html + web: + image: nginx:stable + ports: + - "80:80" + volumes: + - .:/var/www/html:ro + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro +``` + +```nginx +server { + listen 80; + root /var/www/html/public; + index index.php; + + location / { + try_files $uri /index.php$is_args$args; + } + + location ~ \.php$ { + try_files $uri =404; + fastcgi_pass php:9000; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } +} +``` + +## Répertoire de l'application {#application-directory} + +L'application n'a pas besoin d'être dans `/var/www/html` : PHP-FPM exécute le script dont il reçoit le chemin du +serveur web. Montez l'application dans un autre répertoire et donnez son chemin au serveur web : +`APACHE_DOCUMENT_ROOT` avec l'Apache intégré (un chemin absolu), le `root` de nginx… Définissez aussi le répertoire de +travail : par défaut, les commandes tournent avec le propriétaire du répertoire de travail (voir +[Permissions](advanced.md#permissions)). + +```yml +services: + app: + image: thecodingmachine/php:8.6-v5-fpm + working_dir: /var/www + environment: + PHP_FPM_WEB_SERVER: apache + APACHE_DOCUMENT_ROOT: /var/www/public + volumes: + - .:/var/www +``` + +## Plusieurs pools {#several-pools} + +Le pool `www` de PHP-FPM traite toutes les requêtes PHP. Un autre pool peut en traiter une partie avec ses propres +paramètres : nombre de workers, paramètres `php.ini`… par exemple le back-office d'un site WordPress, avec plus de +mémoire et moins de workers. Ajoutez un fichier de pool qui écoute sur un autre port : + +```ini +; admin-pool.conf +[admin] +listen = 9001 +; Même utilisateur que le pool www (avec l'Apache intégré, le processus maître de PHP-FPM tourne en root) +user = ${APACHE_RUN_USER} +group = ${APACHE_RUN_GROUP} +clear_env = no +catch_workers_output = yes +decorate_workers_output = no +pm = ondemand +pm.max_children = 2 +php_admin_value[memory_limit] = 512M +``` + +Avec l'Apache intégré, envoyez les requêtes du back-office à ce pool : + +```apache +# apache-admin-pool.conf + + + SetHandler "proxy:fcgi://127.0.0.1:9001" + + +``` + +```yml +services: + app: + image: thecodingmachine/php:8.6-v5-fpm + environment: + PHP_FPM_WEB_SERVER: apache + volumes: + - .:/var/www/html + - ./admin-pool.conf:/etc/php/8.6/fpm/pool.d/admin.conf:ro + - ./apache-admin-pool.conf:/etc/apache2/conf-enabled/admin-pool.conf:ro +``` + +Avec votre propre serveur web, envoyez ces requêtes au port du pool (`fastcgi_pass php:9001;` dans une `location` de +nginx). + +## Contraintes de PHP-FPM {#constraints-of-php-fpm} + +### Nombre de workers et mémoire {#number-of-workers-and-memory} + +Les requêtes PHP sont traitées par un pool fixe de workers PHP-FPM : **au plus `PHP_FPM_PM_MAX_CHILDREN` requêtes +sont traitées en même temps** (`5` par défaut, la valeur d'Ubuntu). Les autres attendent un worker libre. +Avec la variante *apache*, cette limite est le nombre de processus Apache (`APACHE_MAX_REQUEST_WORKERS`, `150`), qui +servent aussi les fichiers statiques. + +`memory_limit` (`PHP_INI_MEMORY_LIMIT`) est une limite par requête : dans le pire des cas, PHP utilise +`PHP_FPM_PM_MAX_CHILDREN` x `memory_limit`. Calibrez le nombre de workers selon la mémoire du conteneur, par +exemple avec un conteneur de 1 Gio et un `memory_limit` de `128M`, au plus ~6 workers si chaque requête peut atteindre +la limite, davantage si vos requêtes utilisent beaucoup moins de mémoire (vérifiez la mémoire des workers avec +`docker stats` ou `ps`). + +| Variable d'environnement | Défaut | Description | +|--------------------------------|-----------|-------------| +| `PHP_FPM_PM` | `dynamic` | `static` (nombre fixe de workers), `dynamic` ou `ondemand` | +| `PHP_FPM_PM_MAX_CHILDREN` | `5` | Nombre maximal de workers (requêtes traitées en même temps) | +| `PHP_FPM_PM_START_SERVERS` | `2` | Workers démarrés avec PHP-FPM (`dynamic`) | +| `PHP_FPM_PM_MIN_SPARE_SERVERS` | `1` | Nombre minimal de workers inactifs (`dynamic`) | +| `PHP_FPM_PM_MAX_SPARE_SERVERS` | `3` | Nombre maximal de workers inactifs (`dynamic`) | +| `PHP_FPM_PM_MAX_REQUESTS` | `0` | Requêtes traitées par un worker avant son redémarrage (`0` : jamais), utile si votre application fuit de la mémoire | + +Voir la [documentation de PHP-FPM](https://www.php.net/manual/fr/install.fpm.configuration.php) pour les détails, et +le [simulateur de tuning](../tuning/#lang=fr) pour choisir le nombre de workers de votre application, par exemple +une [API avec 1000 utilisateurs](../tuning/#lang=fr&app=api&users=1000&front=proxy). + +### Temps d'exécution {#execution-time} + +`max_execution_time` (`PHP_INI_MAX_EXECUTION_TIME`) et `set_time_limit()` fonctionnent comme avec `mod_php` (sous +Linux, le temps passé dans les appels système, les requêtes à la base de données ou `sleep()` n'est pas compté). + +Mais le serveur web devant PHP-FPM a son propre timeout : si PHP ne répond pas dans les `APACHE_PROXY_TIMEOUT` +secondes (`300` par défaut), l'Apache intégré répond par une erreur `504 Gateway Timeout`, même avec +`set_time_limit(0)`. Avec nginx, le `fastcgi_read_timeout` par défaut est de 60 secondes. Les tâches longues doivent +tourner dans une commande CLI, une [tâche cron](processes.md#cron-jobs) ou un worker de queue. + +### `php_value` dans `.htaccess` {#php_value-in-htaccess} + +Les directives `php_value` et `php_flag` sont des directives de `mod_php` : dans un fichier `.htaccess`, Apache +répond par une erreur `500`. Utilisez les variables d'environnement `PHP_INI_*`, ou un +[fichier `.user.ini`](https://www.php.net/manual/fr/configuration.file.per-user.php) (lu par PHP-FPM, mis en cache +5 minutes). + +### Autres différences {#other-differences} + +- Les variables d'environnement sont lues par PHP-FPM : elles sont disponibles dans `getenv()` et `$_SERVER`, mais ne + sont plus exposées à Apache (`PassEnv`). +- Le header `Authorization` est transmis à PHP (`PHP_AUTH_USER`, `HTTP_AUTHORIZATION`…). +- Les fichiers PHP inexistants reçoivent une erreur `404` d'Apache. +- Les workers PHP-FPM tournent avec l'utilisateur d'Apache (`docker` par défaut), comme `mod_php`. +- Le log d'accès de PHP-FPM est désactivé avec l'Apache intégré : Apache en écrit déjà un. + +## Migrer depuis la variante apache {#migrating-from-the-apache-variant} + +1. Utilisez l'image *fpm* et activez l'Apache intégré : `thecodingmachine/php:8.6-v5-apache` devient + `thecodingmachine/php:8.6-v5-fpm` avec `PHP_FPM_WEB_SERVER=apache`. Gardez vos variables `APACHE_*`. +2. Configurez le nombre de workers PHP (`PHP_FPM_PM_MAX_CHILDREN`) selon votre trafic et votre mémoire (voir plus haut, + ou le [simulateur de tuning](../tuning/#lang=fr)). +3. Remplacez les directives `php_value` / `php_flag` de vos fichiers `.htaccess`. +4. Si vous le souhaitez, utilisez `php-fpm-healthcheck` comme healthcheck (Docker) ou probe (Kubernetes). diff --git a/docs/fr/images.md b/docs/fr/images.md new file mode 100644 index 0000000..206be44 --- /dev/null +++ b/docs/fr/images.md @@ -0,0 +1,136 @@ +# Images + +Toutes les images sont publiées sur [Docker Hub](https://hub.docker.com/r/thecodingmachine/php/tags) sous +`thecodingmachine/php:`. Le tag se lit `-v5-[slim-][-node]` : + +- *slim* : sans extensions préchargées ; sans `slim`, l'image *fat* contient les extensions les plus courantes, + Supercronic et les outils de locales ; +- `-node` : l'image *fat* avec NodeJS, npm et yarn. + +Voir les [variantes](variants.md) pour choisir entre *cli*, *apache* et *fpm*, et les +[versions maintenues](https://github.com/thecodingmachine/docker-images-php#supported-versions) (en anglais). + + +
+## Production : l'image slim {#production-the-slim-image} + +En production, préférez l'image **slim** : elle ne contient que les extensions que vous listez, elle est donc plus +petite et expose moins. L'image **fat**, avec les extensions les plus courantes et Supercronic, est pratique en +développement. + +### Dockerfile avec l'image slim {#dockerfile-with-the-slim-image} + +Les ARG écrits **avant** le `FROM` sont lus par l'image slim pendant le build : `PHP_EXTENSIONS` liste les extensions +à installer, `NODE_VERSION` installe NodeJS (avec npm et yarn), dans n'importe quelle version publiée par +[NodeSource](https://github.com/nodesource/distributions), 16 ou plus, même sans tag `-node`. + +```Dockerfile +ARG PHP_EXTENSIONS="apcu intl pdo_mysql" +ARG NODE_VERSION=24 +FROM thecodingmachine/php:8.6-v5-slim-apache + +ENV TEMPLATE_PHP_INI=production + +COPY --chown=docker:docker . /var/www/html +RUN composer install --no-dev --optimize-autoloader \ + && npm ci \ + && npm run build +``` + +### Dockerfile avec l'image fat {#dockerfile-with-the-fat-image} + +Les extensions s'activent avec `PHP_EXTENSION_=1` (voir [Extensions](extensions.md)), et NodeJS vient avec les +tags `-node`. + +```Dockerfile +FROM thecodingmachine/php:8.6-v5-apache-node24 + +ENV TEMPLATE_PHP_INI=production \ + PHP_EXTENSION_INTL=1 + +COPY --chown=docker:docker . /var/www/html +RUN composer install --no-dev --optimize-autoloader \ + && npm ci \ + && npm run build +``` + +L'image fat ignore l'ARG `NODE_VERSION`. Pour une version de NodeJS sans tag `-node` (ici NodeJS 20), partez de +l'image fat sans NodeJS et installez-le depuis NodeSource ; à partir de NodeJS 25, ajoutez +`sudo npm install -g corepack` avant `corepack enable` : + +```Dockerfile +FROM thecodingmachine/php:8.6-v5-apache + +RUN sudo apt-get update \ + && sudo apt-get install -y --no-install-recommends gnupg \ + && sudo mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list \ + && sudo apt-get update \ + && sudo apt-get install -y --no-install-recommends nodejs \ + && sudo corepack enable && sudo corepack prepare yarn@stable --activate \ + && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* +``` + +### compose.yml + +En développement, avec l'image fat et votre projet monté : + +```yml +services: + app: + image: thecodingmachine/php:8.6-v5-apache + ports: + - "80:80" + volumes: + - .:/var/www/html +``` + +Avec un Dockerfile, remplacez `image:` par `build: .`. Ces exemples utilisent la variante *apache* ; pour *fpm*, +voir [la variante fpm](fpm.md). + +## Tous les tags {#all-the-tags} + +### apache + +| PHP | fat | slim | NodeJS | +|-----|-----|------|--------| +| 8.6 | `8.6-v5-apache` | `8.6-v5-slim-apache` | `8.6-v5-apache-node22` `8.6-v5-apache-node24` `8.6-v5-apache-node26` | +| 8.5 | `8.5-v5-apache` | `8.5-v5-slim-apache` | `8.5-v5-apache-node22` `8.5-v5-apache-node24` `8.5-v5-apache-node26` | +| 8.4 | `8.4-v5-apache` | `8.4-v5-slim-apache` | `8.4-v5-apache-node22` `8.4-v5-apache-node24` `8.4-v5-apache-node26` | +| 8.3 | `8.3-v5-apache` | `8.3-v5-slim-apache` | `8.3-v5-apache-node22` `8.3-v5-apache-node24` `8.3-v5-apache-node26` | +| 8.2 | `8.2-v5-apache` | `8.2-v5-slim-apache` | `8.2-v5-apache-node22` `8.2-v5-apache-node24` `8.2-v5-apache-node26` | +| 8.1 | `8.1-v5-apache` | `8.1-v5-slim-apache` | `8.1-v5-apache-node20` `8.1-v5-apache-node22` `8.1-v5-apache-node24` `8.1-v5-apache-node26` | + +### fpm + +| PHP | fat | slim | NodeJS | +|-----|-----|------|--------| +| 8.6 | `8.6-v5-fpm` | `8.6-v5-slim-fpm` | `8.6-v5-fpm-node22` `8.6-v5-fpm-node24` `8.6-v5-fpm-node26` | +| 8.5 | `8.5-v5-fpm` | `8.5-v5-slim-fpm` | `8.5-v5-fpm-node22` `8.5-v5-fpm-node24` `8.5-v5-fpm-node26` | +| 8.4 | `8.4-v5-fpm` | `8.4-v5-slim-fpm` | `8.4-v5-fpm-node22` `8.4-v5-fpm-node24` `8.4-v5-fpm-node26` | +| 8.3 | `8.3-v5-fpm` | `8.3-v5-slim-fpm` | `8.3-v5-fpm-node22` `8.3-v5-fpm-node24` `8.3-v5-fpm-node26` | +| 8.2 | `8.2-v5-fpm` | `8.2-v5-slim-fpm` | `8.2-v5-fpm-node22` `8.2-v5-fpm-node24` `8.2-v5-fpm-node26` | +| 8.1 | `8.1-v5-fpm` | `8.1-v5-slim-fpm` | `8.1-v5-fpm-node20` `8.1-v5-fpm-node22` `8.1-v5-fpm-node24` `8.1-v5-fpm-node26` | + +### cli + +| PHP | fat | slim | NodeJS | +|-----|-----|------|--------| +| 8.6 | `8.6-v5-cli` | `8.6-v5-slim-cli` | `8.6-v5-cli-node22` `8.6-v5-cli-node24` `8.6-v5-cli-node26` | +| 8.5 | `8.5-v5-cli` | `8.5-v5-slim-cli` | `8.5-v5-cli-node22` `8.5-v5-cli-node24` `8.5-v5-cli-node26` | +| 8.4 | `8.4-v5-cli` | `8.4-v5-slim-cli` | `8.4-v5-cli-node22` `8.4-v5-cli-node24` `8.4-v5-cli-node26` | +| 8.3 | `8.3-v5-cli` | `8.3-v5-slim-cli` | `8.3-v5-cli-node22` `8.3-v5-cli-node24` `8.3-v5-cli-node26` | +| 8.2 | `8.2-v5-cli` | `8.2-v5-slim-cli` | `8.2-v5-cli-node22` `8.2-v5-cli-node24` `8.2-v5-cli-node26` | +| 8.1 | `8.1-v5-cli` | `8.1-v5-slim-cli` | `8.1-v5-cli-node20` `8.1-v5-cli-node22` `8.1-v5-cli-node24` `8.1-v5-cli-node26` | + +## Versions de patch {#patch-releases} + +Chaque version de patch de PHP a aussi son tag, par ex. `8.6.1-v5-cli`. Préférez le tag +`8.6-v5-cli` : il reçoit chaque version de patch (qui ne contient que des correctifs) et chaque +reconstruction des images. Le tag d'une version de patch n'est plus reconstruit une fois la suivante sortie : il ne +reçoit plus aucun correctif de sécurité. Gardez-le pour un besoin précis, par ex. une régression dans la dernière +version de patch, et voir [Sécurité](security.md). + + + diff --git a/docs/fr/index.md b/docs/fr/index.md new file mode 100644 index 0000000..d32d396 --- /dev/null +++ b/docs/fr/index.md @@ -0,0 +1,37 @@ +
+

Des images PHP pour Docker, configurées par des variables d’environnement

+

Des images généralistes : variantes cli, apache et fpm, slim et fat. La liste complète des images et le démarrage rapide sont dans le README (en anglais).

+8.6-v5-apache8.6-v5-fpm8.6-v5-cli8.6-v5-slim-apache8.6-v5-apache-node24 +
docker run -p 80:80 -v "$PWD":/var/www/html \
+  -e PHP_EXTENSION_XDEBUG=1 -e PHP_INI_MEMORY_LIMIT=1g \
+  thecodingmachine/php:8.6-v5-apache
+
+ +## Choix et tuning {#choose-and-size} + + + +## Configurer {#configure} + + + +## Projet {#project} + + + +À venir avec la v6 : une variante FrankenPHP, déjà présente dans le simulateur de tuning. diff --git a/docs/fr/php-configuration.md b/docs/fr/php-configuration.md new file mode 100644 index 0000000..78a4bc5 --- /dev/null +++ b/docs/fr/php-configuration.md @@ -0,0 +1,36 @@ +# Configuration de PHP (php.ini) + +## Fichier php.ini de base {#base-phpini-file} + +Par défaut, le fichier `php.ini` de base est le [php.ini de *développement*](https://github.com/php/php-src/blob/PHP-8.6/php.ini-development) +fourni avec PHP. La variable `TEMPLATE_PHP_INI` choisit plutôt celui de *production* : + +```bash +TEMPLATE_PHP_INI=production +``` + +## Définir les paramètres de php.ini {#setting-phpini-parameters} + +Les variables d'environnement `PHP_INI_` définissent n'importe quel paramètre de `php.ini` : + +```yml +services: + my_app: + image: thecodingmachine/php:8.6-v5-apache + environment: + # memory_limit=1g + PHP_INI_MEMORY_LIMIT: 1g + # error_reporting=E_ALL + PHP_INI_ERROR_REPORTING: E_ALL +``` + +Si le paramètre contient un point (`.`), remplacez-le par un double tiret bas (`__`) : + +```bash +# opcache.validate_timestamps=0 +PHP_INI_OPCACHE__VALIDATE_TIMESTAMPS=0 +# intl.default_locale=fr_FR.UTF-8 +PHP_INI_INTL__DEFAULT_LOCALE=fr_FR.UTF-8 +``` + +Les paramètres s'appliquent à PHP CLI et au PHP de la variante *apache* ou *fpm*. diff --git a/docs/fr/processes.md b/docs/fr/processes.md new file mode 100644 index 0000000..d641a37 --- /dev/null +++ b/docs/fr/processes.md @@ -0,0 +1,119 @@ +# Processus : commandes de démarrage, tâches cron et daemons + +À chaque démarrage, l'entrypoint de l'image : + +1. configure PHP (extensions, `php.ini`), Apache, Composer et les locales à partir des variables d'environnement ; +2. lance les [commandes de démarrage](#startup-commands) ; +3. lance la commande principale (la *command* Docker : Apache, PHP-FPM ou votre commande CLI), avec + [Supercronic](#cron-jobs) et les [daemons](#daemons) s'il y en a. + +
L’entrypoint, puis les commandes de démarrage, puis la commande principale avec les cron jobs et les daemons
+ +## Commandes de démarrage {#startup-commands} + +Les variables `STARTUP_COMMAND_` sont lancées dans l'ordre de leur suffixe avant la commande principale, par +exemple pour installer les dépendances ou appliquer les migrations de la base de données : + +```bash +STARTUP_COMMAND_1=composer install +STARTUP_COMMAND_2=vendor/bin/doctrine orm:schema-tool:update +``` + +Elles sont lancées par l'utilisateur `docker` (voir [Permissions](advanced.md#permissions)), ou par l'utilisateur +d'ID `UID` si cette variable est définie (par ex. `UID=0` pour `root`). Le conteneur s'arrête si une commande échoue. + +Autre possibilité, un fichier exécutable monté sur `/etc/container/startup.sh` est lancé avant ces commandes : + +```bash +$ docker run --rm -v "$PWD":/usr/src/app -v "$PWD/my-startup-script.sh":/etc/container/startup.sh \ + thecodingmachine/php:8.6-v5-cli php your-script.php +``` + +## Tâches cron {#cron-jobs} + +Les variables `CRON_SCHEDULE`, `CRON_COMMAND` et (si besoin) `CRON_USER` définissent une tâche cron : + +```bash +# L'utilisateur qui lance la tâche (root par défaut) +CRON_USER=root +# La planification (ici : toutes les minutes) +CRON_SCHEDULE=* * * * * +# La commande +CRON_COMMAND=vendor/bin/console do:stuff +``` + +Pour plusieurs tâches, ajoutez le même suffixe aux variables de chaque tâche : + +```bash +CRON_USER_1=root +CRON_SCHEDULE_1=* * * * * +CRON_COMMAND_1=vendor/bin/console do:stuff + +CRON_USER_2=www-data +CRON_SCHEDULE_2=0 3 * * * +CRON_COMMAND_2=vendor/bin/console other:stuff +``` + +La sortie des tâches est envoyée dans les logs Docker. + +Les conteneurs tournent dans le fuseau horaire UTC : la variable `TZ` le change. + +```bash +# Lance cette tâche à 1 h, heure de Paris +TZ=Europe/Paris +CRON_SCHEDULE_1=0 1 * * * +CRON_COMMAND_1=vendor/bin/console do:stuff +``` + +Les tâches sont lancées par [Supercronic](https://github.com/aptible/supercronic), un remplaçant de cron conçu pour +les conteneurs. Il est **installé par défaut dans les images fat**. Avec une image slim, installez-le avec un ARG avant +le `FROM` : + +```Dockerfile +ARG INSTALL_CRON=1 +FROM thecodingmachine/php:8.6-v5-slim-apache +``` + +`SUPERCRONIC_OPTIONS` passe des options à Supercronic. Par exemple, par défaut, une tâche n'est pas relancée tant que +son exécution précédente n'est pas terminée ; `-overlapping` le permet : + +```bash +SUPERCRONIC_OPTIONS=-overlapping -debug +``` + +Voir la [documentation de Supercronic](https://github.com/aptible/supercronic/blob/master/README.md) pour les autres +options. + +Supercronic est supervisé comme les [daemons](#daemons) : s'il s'arrête, le conteneur s'arrête. + +**Important** : les tâches tournent dans chaque conteneur démarré avec votre configuration. Si votre application passe +à plusieurs conteneurs, une tâche qui doit tourner une fois par application (et non une fois par conteneur) relève de +votre orchestrateur (par ex. un CronJob Kubernetes) ou d'un conteneur dédié. + +## Daemons {#daemons} + +**Préférez un conteneur par processus.** Par exemple, lancez un worker de queue Laravel dans son propre conteneur +(l'image *cli*, avec `php artisan queue:work` comme commande) plutôt que dans le conteneur Apache : Docker et votre +orchestrateur peuvent alors redémarrer, multiplier, limiter et surveiller chaque processus. + +Quand un conteneur séparé n'est pas possible, les variables `DAEMON_COMMAND_` démarrent des processus de +longue durée avec la commande principale. Ils sont lancés par l'utilisateur `docker` (voir +[Permissions](advanced.md#permissions)), ou par l'utilisateur défini dans la variable `DAEMON_USER_` de même +suffixe (un nom d'utilisateur ou un ID) : + +```bash +DAEMON_COMMAND_1=php artisan queue:work +DAEMON_COMMAND_2=php artisan horizon +DAEMON_USER_2=www-data +``` + +Une commande qui se termine, comme `composer install`, est une [commande de démarrage](#startup-commands), pas un +daemon : sa fin arrêterait le conteneur. + +Ces processus ne sont pas redémarrés : **dès que l'un d'eux (ou la commande principale) s'arrête, les autres sont +arrêtés et le conteneur s'arrête** avec le code de sortie de ce processus. Utilisez une politique de redémarrage (par +ex. `restart: unless-stopped`) pour redémarrer le conteneur. + +Quand le conteneur s'arrête (`docker stop` ou un processus qui s'est terminé), Apache et PHP-FPM s'arrêtent proprement +(les requêtes en cours se terminent), et les autres processus (une autre commande principale, les daemons et +Supercronic) reçoivent `SIGTERM`. diff --git a/docs/fr/security.md b/docs/fr/security.md new file mode 100644 index 0000000..8bb9628 --- /dev/null +++ b/docs/fr/security.md @@ -0,0 +1,87 @@ +# Sécurité + +## Le traitement des versions de sécurité de PHP {#how-the-security-releases-of-php-are-handled} + +Les images prennent PHP dans les [paquets d'Ondřej Surý](https://packages.sury.org/php/). Quand une version de +sécurité de PHP est annoncée : + +1. Une issue est ouverte sur ce dépôt : abonnez-vous pour être prévenu, posez-y vos questions. Sa description donne + l'état de chaque image, vérifié toutes les 5 minutes, et un commentaire est publié quand il change, au plus toutes + les 30 minutes. +2. Chaque version de PHP est reconstruite dès que ses paquets corrigés sont publiés sur amd64 **ou** arm64, puis + reconstruite à nouveau quand l'autre architecture suit : sury publie les paquets arm64 plus tard, parfois un jour + plus tard. + +En dehors des versions de sécurité, chaque version de PHP est aussi reconstruite dans la journée quand sury publie de +nouveaux paquets. + +Les tags des images : + +- `X.Y-v5-*` (par ex. `8.6-v5-apache`) est mis à jour à chaque build : utilisez-le pour recevoir les correctifs. +- `X.Y.Z-v5-*` (par ex. `8.4.28-v5-apache`) est le dernier build de PHP X.Y.Z : il est publié dès qu'amd64 et arm64 + ont la même version de PHP, puis mis à jour par chaque build jusqu'à la version suivante de PHP. Utilisez le digest + d'une image pour la figer. +- PHP 7.4, 8.0 et 8.1 ne sont pas maintenus : ils sont reconstruits quand sury publie un correctif pour eux, qui garde + le numéro de version de PHP, sans nouveau tag `X.Y.Z`. + +## Mainteneurs : suivre une version de sécurité {#maintainers-following-a-security-release} + +[`php-watch.yml`](../../.github/workflows/php-watch.yml) vérifie les paquets de sury chaque jour, et lance +`workflow.yml` et `legacy-v5.yml` pour chaque version de PHP dont les images ne les ont pas. Les planifications de +GitHub peuvent démarrer avec des heures de retard : pour une version de sécurité, lancez-le à la main la veille, il +vérifie toutes les 5 minutes à partir de `start_at` : + +```bash +$ gh variable set SECURITY_RELEASE --body 1 +$ gh workflow run php-watch.yml --ref v5 -f issue=437 -f start_at="2026-12-17 13:45" -f until="2026-12-19 14:00" \ + -f fixed="8.5=8.5.14 8.4=8.4.29 8.3=8.3.38 8.2=8.2.37" +``` + +- `fixed` donne les versions corrigées une fois connues (la surveillance peut être relancée avec elles) : le tableau + indique corrigée ou vulnérable au lieu de à jour. Sans `fixed`, la surveillance s'arrête dès que les images ont les + paquets de sury. +- `SECURITY_RELEASE=1` met en pause les builds des pushs, des pull requests et le build hebdomadaire avec sa purge du + cache : seules les reconstructions de la surveillance publient des images. Le label `force-ci` lance quand même la + CI d'une pull request. +- Ensuite : `gh variable set SECURITY_RELEASE --body 0`, puis `gh workflow run workflow.yml --ref v5` pour publier les + commits mergés entre-temps. + +## Que faire une fois votre version corrigée {#what-to-do-once-your-version-is-fixed} + +1. Tirez à nouveau les images et recréez vos conteneurs : + + ```bash + $ docker compose pull && docker compose up -d + ``` + +2. Reconstruisez les images construites à partir des nôtres, sans le cache de l'image de base : + + ```bash + $ docker build --pull -t my-app . + ``` + + Dans votre CI, vérifiez que l'image de base est bien tirée à nouveau et non prise dans un cache. + +3. Comparez la version de PHP de vos conteneurs (`php -v`) aux versions corrigées données dans l'issue. + +[Watchtower](https://github.com/nicholas-fedor/watchtower) tire les nouvelles versions des images et recrée les +conteneurs, pour que les prochains correctifs de sécurité s'appliquent sans vous attendre : + +```bash +$ docker run -d --name watchtower -v /var/run/docker.sock:/var/run/docker.sock \ + ghcr.io/nicholas-fedor/watchtower +``` + +Les images v4 ne reçoivent aucun correctif de sécurité : migrez vers la v5, voir les +[notes de migration](../../MIGRATING.md#migrating-from-v4-to-v5-images) (en anglais). + +## Alertes passées {#past-advisories} + +- 2026-11-19 : [17 vulnérabilités](https://www.php.net/archive/2026.php#2026-11-19-4), dont 7 critiques + (CVE-2026-115560, CVE-2026-126714, CVE-2026-129481, CVE-2026-129496, CVE-2026-129289, CVE-2026-129474, + CVE-2026-129182), corrigées dans PHP 8.2.36, 8.3.37, 8.4.28 et 8.5.13. PHP 7.4, 8.0 et 8.1 ont reçu le backport de + sury des 12 vulnérabilités corrigées dans 8.2.36 (`1:7.4.33-36`, `1:8.0.30-30`, `8.1.34-13`). Toutes les images v5 + ont été corrigées sur amd64 le 2026-11-19 et sur arm64 le 2026-11-20. Voir + l'[issue #437](https://github.com/thecodingmachine/docker-images-php/issues/437). +- 2026-10-21 : [php2shell](https://github.com/thecodingmachine/docker-images-php/blob/94f9647557c4fb8af550ba714c49bbf566a33458/docs/security-php2shell.md) + (CVE-2026-109618 et CVE-2026-109619), corrigée dans toutes les images v5. diff --git a/docs/fr/variants.md b/docs/fr/variants.md new file mode 100644 index 0000000..cc4a2a9 --- /dev/null +++ b/docs/fr/variants.md @@ -0,0 +1,233 @@ +# Variantes : cli, apache et fpm + +| Variante | Commande par défaut | Répertoire de travail | Port | +|----------|----------------------|-----------------------|------------------------------------------------------------------| +| cli | `php -v` | `/usr/src/app` | - | +| apache | `apache2-foreground` | `/var/www/html` | `80` (HTTP) | +| fpm | `php-fpm` | `/var/www/html` | `9000` (FastCGI, pas de HTTP), `80` (HTTP) avec l'Apache intégré | + +Montez ou copiez votre application dans le répertoire de travail. + +
Les 3 variantes en images slim, fat et node
+ +## cli {#cli} + +Les images *cli* attendent une commande : remplacez la *command* Docker, jamais l'*entrypoint* (il configure PHP, +l'utilisateur, les tâches cron… voir [Processus](processes.md)). + +```Dockerfile +FROM thecodingmachine/php:8.6-v5-cli + +CMD ["php", "myprogram.php", "some_param"] +``` + +```yml +services: + my_app: + image: thecodingmachine/php:8.6-v5-cli + command: php myprogram.php some_param +``` + +## apache {#apache} + +Apache exécute PHP avec `mod_php`. Les sections ci-dessous s'appliquent aussi à +l'[Apache intégré de la variante *fpm*](#built-in-apache). + +Pour une nouvelle application, préférez la variante *fpm* avec son Apache intégré : les mêmes fonctionnalités, +avec 63 % de trafic servi en plus en HTTPS et jusqu'à 29 % de plus pendant un pic de trafic +([benchmark](../../benchmarks/capacity/README.md)). Voir [La variante fpm](fpm.md) et ses +[notes de migration](fpm.md#migrating-from-the-apache-variant). + +### Racine web {#document-root} + +`APACHE_DOCUMENT_ROOT` définit la racine web (votre répertoire « public »). Un chemin relatif part de +`/var/www/html` : + +```bash +# Ces 2 variables sont identiques +APACHE_DOCUMENT_ROOT=public/ +APACHE_DOCUMENT_ROOT=/var/www/html/public +``` + +### Ports {#ports} + +Apache écoute sur le port 80 (et 443 quand le module `ssl` est activé). `APACHE_HTTP_PORT` et `APACHE_HTTPS_PORT` +changent ces ports, par exemple pour utiliser des ports non privilégiés : + +```bash +APACHE_HTTP_PORT=8080 +APACHE_HTTPS_PORT=8443 +``` + +### Modules Apache {#apache-modules} + +Utilisez les variables d'environnement `APACHE_EXTENSION_` : + +```yml +services: + my_app: + image: thecodingmachine/php:8.6-v5-apache + environment: + APACHE_EXTENSION_DAV: 1 + APACHE_EXTENSION_SSL: 1 +``` + +Autre possibilité, la variable `APACHE_EXTENSIONS` liste les modules à activer : + +```bash +APACHE_EXTENSIONS="dav ssl" +``` + +**Modules activés par défaut :** `access_compat` `alias` `auth_basic` `authn_core` `authn_file` `authz_core` +`authz_host` `authz_user` `autoindex` `deflate` `dir` `env` `expires` `filter` `mime` `mpm_prefork` `negotiation` +`php8.x` (votre version de PHP) `reqtimeout` `rewrite` `setenvif` `status` + +Pour l'Apache intégré de la variante *fpm*, `mpm_event` `proxy` `proxy_fcgi` sont activés à la place de `mpm_prefork` +et `php8.x` (`mod_php` n'est pas disponible). + +**Modules disponibles :** `access_compat` `actions` `alias` `allowmethods` `asis` `auth_basic` `auth_digest` `auth_form` +`authn_anon` `authn_core` `authn_dbd` `authn_dbm` `authn_file` `authn_socache` `authnz_fcgi` `authnz_ldap` +`authz_core` `authz_dbd` `authz_dbm` `authz_groupfile` `authz_host` `authz_owner` `authz_user` `autoindex` `brotli` +`buffer` `cache` `cache_disk` `cache_socache` `cern_meta` `cgi` `cgid` `charset_lite` `data` `dav` `dav_fs` +`dav_lock` `dbd` `deflate` `dialup` `dir` `dump_io` `echo` `env` `ext_filter` `expires` `file_cache` `filter` +`headers` `heartbeat` `heartmonitor` `ident` `imagemap` `include` `info` `lbmethod_bybusyness` +`lbmethod_byrequests` `lbmethod_bytraffic` `lbmethod_heartbeat` `ldap` `log_debug` `log_forensic` `lua` `macro` `md` +`mime` `mime_magic` `mpm_event` `mpm_prefork` `mpm_worker` `negotiation` `php8.x` `proxy` `proxy_ajp` +`proxy_balancer` `proxy_connect` `proxy_express` `proxy_fcgi` `proxy_fdpass` `proxy_ftp` `proxy_hcheck` `proxy_html` +`proxy_http` `proxy_scgi` `proxy_uwsgi` `proxy_wstunnel` `ratelimit` `reflector` `remoteip` `reqtimeout` `request` +`rewrite` `sed` `session` `session_cookie` `session_crypto` `session_dbd` `setenvif` `slotmem_plain` `slotmem_shm` +`socache_dbm` `socache_memcache` `socache_redis` `socache_shmcb` `speling` `ssl` `status` `substitute` `suexec` +`unique_id` `userdir` `usertrack` `vhost_alias` `xml2enc` + +Cette liste peut être obsolète, vous pouvez la vérifier avec : `docker run --rm thecodingmachine/php:8.6-v5-slim-apache a2enmod` + +### Connexions et processus {#connections-and-processes} + +| Variable d'environnement | Variante *apache* (`mpm_prefork`) | Variante *fpm* (`mpm_event`) | Description | +|------------------------------|-----------------------------------|------------------------------|-------------| +| `APACHE_MAX_REQUEST_WORKERS` | `150` | `150` | `MaxRequestWorkers` : nombre maximal de processus Apache (chacun embarque PHP) ou de threads (jusqu'à 1600) | +| `APACHE_KEEPALIVE` | `On` | `On` | `KeepAlive` avec les clients | +| `APACHE_KEEPALIVE_TIMEOUT` | `5` | `5` | `KeepAliveTimeout`, en secondes | + +Avec `mod_php`, un processus est occupé pendant toute la vie d'une connexion, y compris le temps d'inactivité d'une +connexion keep-alive, et utilise la mémoire d'une requête PHP : derrière un reverse proxy, désactivez le keep-alive +(`APACHE_KEEPALIVE=Off`) et calibrez `APACHE_MAX_REQUEST_WORKERS` selon la mémoire du conteneur (150 processus de +100 Mo demandent 15 Go). + +Le [simulateur de tuning](../tuning/#lang=fr) choisit ces paramètres (et ceux de PHP-FPM) pour votre application, vos +utilisateurs et votre conteneur, par exemple un [CRM avec 20 salariés](../tuning/#lang=fr&app=crm&users=20&front=proxy) ou +un [site WordPress avec 100 visiteurs et HTTPS dans le conteneur](../tuning/#lang=fr&app=wp&users=100&front=https). + +### Derrière un reverse proxy {#behind-a-reverse-proxy} + +Derrière Traefik, nginx ou un ingress Kubernetes, listez les proxys dans `APACHE_TRUSTED_PROXIES`, et définissez +`APACHE_TRUSTED_CLOUDFLARE=1` derrière Cloudflare : Apache et PHP obtiennent l'IP des utilisateurs (`REMOTE_ADDR`, +log d'accès, `Require ip`) et `HTTPS=on` pour les requêtes que le proxy a reçues en HTTPS. Le conteneur vérifie +lui-même l'adresse de chaque intermédiaire : un header `X-Forwarded-For` ou `CF-Connecting-IP` falsifié est ignoré. + +```yml +services: + app: + image: thecodingmachine/php:8.6-v5-fpm + environment: + PHP_FPM_WEB_SERVER: apache + # Le nom du service Traefik + APACHE_TRUSTED_PROXIES: traefik + # Les plages de Cloudflare (mises à jour chaque jour) ; "only" refuse aussi les requêtes envoyées sans Cloudflare + APACHE_TRUSTED_CLOUDFLARE: "1" +``` + +Le [guide du reverse proxy](../reverse-proxy/#lang=fr) donne la configuration de votre installation (Traefik, nginx, +Kubernetes, avec ou sans Cloudflare) et explique pourquoi les trusted proxies de Symfony ou Laravel ne suffisent pas. + +### Logs {#logs} + +Le log d'accès va sur la sortie standard du conteneur et le log d'erreurs sur sa sortie d'erreur +(`docker compose logs app`). `APACHE_LOG_FORMAT` choisit le format du log d'accès : `combined` (par défaut), +`detailed` (combined + temps de réponse en µs + adresse du proxy), `json`, ou un +[format de mod_log_config](https://httpd.apache.org/docs/2.4/mod/mod_log_config.html#formats) écrit tel quel. + +`APACHE_LOG_OUTPUT=file` les écrit plutôt dans `/var/log/apache2`, un fichier par jour (`access.2026-11-13.log`, +`error.2026-11-13.log`), avec une rotation à minuit UTC, compressés en gzip et supprimés après +`APACHE_LOG_RETENTION_DAYS` jours (14 par défaut). `APACHE_LOG_MAX_SIZE` (`100M`, `1G`) commence aussi un nouveau +fichier quand il atteint cette taille, les noms prenant alors l'heure (`access.2026-11-13.143002.log`). Montez un +répertoire du serveur ou un volume sur `/var/log/apache2` : sans cela, les logs sont perdus avec le conteneur. + +```yml +services: + app: + image: thecodingmachine/php:8.6-v5-apache + environment: + APACHE_LOG_FORMAT: json + APACHE_LOG_OUTPUT: file + APACHE_LOG_RETENTION_DAYS: 30 + APACHE_LOG_MAX_SIZE: 100M + volumes: + - ./logs:/var/log/apache2 +``` + +### Utilisateur Apache {#apache-user} + +Apache tourne sous l'utilisateur `docker`, qui a les droits du propriétaire de vos fichiers (voir +[Permissions](advanced.md#permissions)). En production, faites-le plutôt tourner sous `www-data` : + +```Dockerfile +FROM thecodingmachine/php:8.6-v5-apache + +ENV APACHE_RUN_USER=www-data \ + APACHE_RUN_GROUP=www-data +``` + +## fpm {#fpm} + +PHP-FPM écoute sur le port 9000 et parle FastCGI, pas HTTP : placez un serveur web (nginx, Caddy, Apache…) devant lui, +dans un autre conteneur, et faites-le pointer vers `fpm-container:9000`. + +```bash +$ docker run -p 9000:9000 --rm -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm +``` + +Un `docker stop` arrête PHP-FPM proprement (`SIGQUIT`), avec ou sans l'Apache intégré : les requêtes en cours se +terminent. + +### Apache intégré {#built-in-apache} + +Avec `PHP_FPM_WEB_SERVER=apache`, la variante *fpm* fait tourner Apache (`mpm_event`) devant PHP-FPM, dans le même +conteneur, avec les fonctionnalités Apache de la variante *apache* (`.htaccess`, [racine web](#document-root), +[ports](#ports), [modules](#apache-modules)). Le nombre de workers PHP se configure indépendamment (voir +[Paramètres de PHP-FPM](#php-fpm-settings)), et `APACHE_PROXY_TIMEOUT` fixe combien de temps Apache attend PHP-FPM +(`300` secondes par défaut). + +```bash +$ docker run -p 80:80 --rm -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm +``` + +[Exécuter une application avec la variante fpm](fpm.md) détaille ses avantages, les contraintes de PHP-FPM (nombre de +workers et mémoire, timeouts, `php_value` dans `.htaccess`), comment utiliser plutôt votre propre serveur web +(nginx…) et comment migrer depuis la variante *apache*. + +### Paramètres de PHP-FPM {#php-fpm-settings} + +Le gestionnaire de processus de PHP-FPM se configure par des variables d'environnement (les valeurs par défaut sont +celles du paquet Ubuntu) : + +| Variable d'environnement | Paramètre de `php-fpm.conf` | Défaut | +|--------------------------------|---------------------------|-------------------| +| `PHP_FPM_PM` | `pm` | `dynamic` | +| `PHP_FPM_PM_MAX_CHILDREN` | `pm.max_children` | `5` | +| `PHP_FPM_PM_START_SERVERS` | `pm.start_servers` | `2` | +| `PHP_FPM_PM_MIN_SPARE_SERVERS` | `pm.min_spare_servers` | `1` | +| `PHP_FPM_PM_MAX_SPARE_SERVERS` | `pm.max_spare_servers` | `3` | +| `PHP_FPM_PM_MAX_REQUESTS` | `pm.max_requests` | `0` | +| `PHP_FPM_ACCESS_LOG` | `access.log` | `/proc/self/fd/2` | + +La commande `php-fpm-healthcheck` vérifie que PHP-FPM répond (sur son point d'accès `/ping`). Vous pouvez l'utiliser +comme healthcheck Docker ou comme sonde Kubernetes : + +```yml +services: + my_app: + image: thecodingmachine/php:8.6-v5-fpm + healthcheck: + test: ["CMD", "php-fpm-healthcheck"] +``` diff --git a/docs/images.md b/docs/images.md new file mode 100644 index 0000000..7e10d78 --- /dev/null +++ b/docs/images.md @@ -0,0 +1,134 @@ +# Images + +All the images are published on [Docker Hub](https://hub.docker.com/r/thecodingmachine/php/tags) as +`thecodingmachine/php:`. A tag reads `-v5-[slim-][-node]`: + +- *slim*: no extensions preloaded; without `slim`, the *fat* image has the most common extensions, Supercronic and the + locale tools; +- `-node`: the *fat* image with NodeJS, npm and yarn. + +See the [variants](variants.md) to choose between *cli*, *apache* and *fpm*, and the +[supported versions](https://github.com/thecodingmachine/docker-images-php#supported-versions). + + +
+## Production: the slim image + +In production, prefer the **slim** image: it contains only the extensions you list, so it is smaller and exposes +less. The **fat** image, with the most common extensions and Supercronic, is handy in development. + +### Dockerfile with the slim image + +The ARGs written **before** the `FROM` are read by the slim image during the build: `PHP_EXTENSIONS` lists the +extensions to install, `NODE_VERSION` installs NodeJS (with npm and yarn), in any version published by +[NodeSource](https://github.com/nodesource/distributions), 16 or later, even without a `-node` tag. + +```Dockerfile +ARG PHP_EXTENSIONS="apcu intl pdo_mysql" +ARG NODE_VERSION=24 +FROM thecodingmachine/php:8.6-v5-slim-apache + +ENV TEMPLATE_PHP_INI=production + +COPY --chown=docker:docker . /var/www/html +RUN composer install --no-dev --optimize-autoloader \ + && npm ci \ + && npm run build +``` + +### Dockerfile with the fat image + +The extensions are enabled with `PHP_EXTENSION_=1` (see [Extensions](extensions.md)), and NodeJS comes with +the `-node` tags. + +```Dockerfile +FROM thecodingmachine/php:8.6-v5-apache-node24 + +ENV TEMPLATE_PHP_INI=production \ + PHP_EXTENSION_INTL=1 + +COPY --chown=docker:docker . /var/www/html +RUN composer install --no-dev --optimize-autoloader \ + && npm ci \ + && npm run build +``` + +The fat image ignores the `NODE_VERSION` ARG. For a NodeJS version without a `-node` tag (here NodeJS 20), start +from the fat image without NodeJS and install it from NodeSource; from NodeJS 25, add +`sudo npm install -g corepack` before `corepack enable`: + +```Dockerfile +FROM thecodingmachine/php:8.6-v5-apache + +RUN sudo apt-get update \ + && sudo apt-get install -y --no-install-recommends gnupg \ + && sudo mkdir -p /etc/apt/keyrings \ + && curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \ + && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list \ + && sudo apt-get update \ + && sudo apt-get install -y --no-install-recommends nodejs \ + && sudo corepack enable && sudo corepack prepare yarn@stable --activate \ + && sudo apt-get clean && sudo rm -rf /var/lib/apt/lists/* +``` + +### compose.yml + +In development, with the fat image and your project mounted: + +```yml +services: + app: + image: thecodingmachine/php:8.6-v5-apache + ports: + - "80:80" + volumes: + - .:/var/www/html +``` + +With a Dockerfile, replace `image:` with `build: .`. These examples use the *apache* variant; for *fpm*, see +[the fpm variant](fpm.md). + +## All the tags + +### apache + +| PHP | fat | slim | NodeJS | +|-----|-----|------|--------| +| 8.6 | `8.6-v5-apache` | `8.6-v5-slim-apache` | `8.6-v5-apache-node22` `8.6-v5-apache-node24` `8.6-v5-apache-node26` | +| 8.5 | `8.5-v5-apache` | `8.5-v5-slim-apache` | `8.5-v5-apache-node22` `8.5-v5-apache-node24` `8.5-v5-apache-node26` | +| 8.4 | `8.4-v5-apache` | `8.4-v5-slim-apache` | `8.4-v5-apache-node22` `8.4-v5-apache-node24` `8.4-v5-apache-node26` | +| 8.3 | `8.3-v5-apache` | `8.3-v5-slim-apache` | `8.3-v5-apache-node22` `8.3-v5-apache-node24` `8.3-v5-apache-node26` | +| 8.2 | `8.2-v5-apache` | `8.2-v5-slim-apache` | `8.2-v5-apache-node22` `8.2-v5-apache-node24` `8.2-v5-apache-node26` | +| 8.1 | `8.1-v5-apache` | `8.1-v5-slim-apache` | `8.1-v5-apache-node20` `8.1-v5-apache-node22` `8.1-v5-apache-node24` `8.1-v5-apache-node26` | + +### fpm + +| PHP | fat | slim | NodeJS | +|-----|-----|------|--------| +| 8.6 | `8.6-v5-fpm` | `8.6-v5-slim-fpm` | `8.6-v5-fpm-node22` `8.6-v5-fpm-node24` `8.6-v5-fpm-node26` | +| 8.5 | `8.5-v5-fpm` | `8.5-v5-slim-fpm` | `8.5-v5-fpm-node22` `8.5-v5-fpm-node24` `8.5-v5-fpm-node26` | +| 8.4 | `8.4-v5-fpm` | `8.4-v5-slim-fpm` | `8.4-v5-fpm-node22` `8.4-v5-fpm-node24` `8.4-v5-fpm-node26` | +| 8.3 | `8.3-v5-fpm` | `8.3-v5-slim-fpm` | `8.3-v5-fpm-node22` `8.3-v5-fpm-node24` `8.3-v5-fpm-node26` | +| 8.2 | `8.2-v5-fpm` | `8.2-v5-slim-fpm` | `8.2-v5-fpm-node22` `8.2-v5-fpm-node24` `8.2-v5-fpm-node26` | +| 8.1 | `8.1-v5-fpm` | `8.1-v5-slim-fpm` | `8.1-v5-fpm-node20` `8.1-v5-fpm-node22` `8.1-v5-fpm-node24` `8.1-v5-fpm-node26` | + +### cli + +| PHP | fat | slim | NodeJS | +|-----|-----|------|--------| +| 8.6 | `8.6-v5-cli` | `8.6-v5-slim-cli` | `8.6-v5-cli-node22` `8.6-v5-cli-node24` `8.6-v5-cli-node26` | +| 8.5 | `8.5-v5-cli` | `8.5-v5-slim-cli` | `8.5-v5-cli-node22` `8.5-v5-cli-node24` `8.5-v5-cli-node26` | +| 8.4 | `8.4-v5-cli` | `8.4-v5-slim-cli` | `8.4-v5-cli-node22` `8.4-v5-cli-node24` `8.4-v5-cli-node26` | +| 8.3 | `8.3-v5-cli` | `8.3-v5-slim-cli` | `8.3-v5-cli-node22` `8.3-v5-cli-node24` `8.3-v5-cli-node26` | +| 8.2 | `8.2-v5-cli` | `8.2-v5-slim-cli` | `8.2-v5-cli-node22` `8.2-v5-cli-node24` `8.2-v5-cli-node26` | +| 8.1 | `8.1-v5-cli` | `8.1-v5-slim-cli` | `8.1-v5-cli-node20` `8.1-v5-cli-node22` `8.1-v5-cli-node24` `8.1-v5-cli-node26` | + +## Patch releases + +Each patch release of PHP also has its tag, e.g. `8.6.1-v5-cli`. Prefer the +`8.6-v5-cli` tag: it gets every patch release (which only contains bug fixes) and every rebuild of +the images. The tag of a patch release is no longer rebuilt once the next one is out: it gets no more security fixes. +Keep it for a specific need, e.g. a regression in the latest patch release, and see [Security](security.md). + + + diff --git a/docs/index.md b/docs/index.md index b3cd0d5..0ff747d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,28 +1,37 @@ -# thecodingmachine/php documentation - -General purpose PHP images for Docker: *cli*, *apache* and *fpm* variants, slim and fat images, configured with -environment variables. The list of images and the quick start are in the -[README](https://github.com/thecodingmachine/docker-images-php#readme). - -## Choose and size - -- [Tuning simulator](tuning/): pick your kind of application and your number of users, get the variant to use and - its settings. -- [Variants](variants.md): *cli*, *apache* (document root, ports, modules, connections) and *fpm*. -- [Serving with the fpm variant](fpm.md): built-in Apache or your own web server, constraints of PHP-FPM, migration from - the *apache* variant. - -## Configure - -- [PHP extensions](extensions.md) -- [PHP configuration (php.ini)](php-configuration.md) -- [Processes: startup commands, cron jobs and daemons](processes.md) -- [Debugging, profiling, coverage](debugging/): from your needs, the tools to load in development, in the CI and in production, and the configuration of your IDE, your AI agent and each environment -- [Advanced features](advanced.md) - -## Project - -- [Security](security.md) -- [Contributing](contributing.md) - -Coming with v6: a [FrankenPHP](https://frankenphp.dev/) variant, previewed in the [tuning simulator](tuning/). +
+

PHP images for Docker, configured with environment variables

+

General purpose images: cli, apache and fpm variants, slim and fat. The full list of images and the quick start are in the README.

+8.6-v5-apache8.6-v5-fpm8.6-v5-cli8.6-v5-slim-apache8.6-v5-apache-node24 +
docker run -p 80:80 -v "$PWD":/var/www/html \
+  -e PHP_EXTENSION_XDEBUG=1 -e PHP_INI_MEMORY_LIMIT=1g \
+  thecodingmachine/php:8.6-v5-apache
+
+ +## Choose and tune {#choose-and-size} + + + +## Configure {#configure} + + + +## Project {#project} + + + +Coming with v6: a FrankenPHP variant, previewed in the tuning simulator. diff --git a/docs/php-configuration.md b/docs/php-configuration.md index 8ee9b7d..d507ce9 100644 --- a/docs/php-configuration.md +++ b/docs/php-configuration.md @@ -2,7 +2,7 @@ ## Base php.ini file -By default, the base `php.ini` file is the [*development* php.ini](https://github.com/php/php-src/blob/PHP-8.4/php.ini-development) +By default, the base `php.ini` file is the [*development* php.ini](https://github.com/php/php-src/blob/PHP-8.6/php.ini-development) file that comes with PHP. The `TEMPLATE_PHP_INI` variable selects the *production* one instead: ```bash @@ -16,7 +16,7 @@ The `PHP_INI_` environment variables set any `php.ini` parameter: ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache environment: # memory_limit=1g PHP_INI_MEMORY_LIMIT: 1g diff --git a/docs/processes.md b/docs/processes.md index 3ab7416..aa5e78c 100644 --- a/docs/processes.md +++ b/docs/processes.md @@ -7,6 +7,8 @@ On each start, the entrypoint of the image: 3. runs the main command (the Docker *command*: Apache, PHP-FPM or your CLI command), along with [Supercronic](#cron-jobs) and the [daemons](#daemons) if any. +
The entrypoint, then the startup commands, then the main command with cron jobs and daemons
+ ## Startup commands The `STARTUP_COMMAND_` variables are run in the order of their suffix before the main command, for instance @@ -24,7 +26,7 @@ As an alternative, an executable file mounted at `/etc/container/startup.sh` is ```bash $ docker run --rm -v "$PWD":/usr/src/app -v "$PWD/my-startup-script.sh":/etc/container/startup.sh \ - thecodingmachine/php:8.4-v5-cli php your-script.php + thecodingmachine/php:8.6-v5-cli php your-script.php ``` ## Cron jobs @@ -68,7 +70,7 @@ It is **installed by default in the fat images**. With a slim image, install it ```Dockerfile ARG INSTALL_CRON=1 -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ``` `SUPERCRONIC_OPTIONS` passes options to Supercronic. For instance, by default, a job is not started again while its diff --git a/docs/reverse-proxy/index.html b/docs/reverse-proxy/index.html index 67b3484..5e883b5 100644 --- a/docs/reverse-proxy/index.html +++ b/docs/reverse-proxy/index.html @@ -1,12 +1,15 @@ --- layout: default title: Behind a reverse proxy +title_fr: Derrière un reverse proxy +bilingual: true wide: true description: Get the real IP of your users behind Traefik, nginx, a Kubernetes ingress or Cloudflare, without trusting forged headers. +description_fr: Obtenez la vraie IP de vos utilisateurs derrière Traefik, nginx, un ingress Kubernetes ou Cloudflare, sans faire confiance aux headers falsifiés. --- -

Behind a reverse proxy: the real IP of your users

-

Behind Traefik, nginx, a Kubernetes ingress or Cloudflare, Apache and PHP see the address of the proxy, +

Behind a reverse proxy: the real IP of your usersDerrière un reverse proxy : la vraie IP de vos utilisateurs

+

Behind Traefik, nginx, a Kubernetes ingress or Cloudflare, Apache and PHP see the address of the proxy, not the one of your users. List your proxies in APACHE_TRUSTED_PROXIES, and set APACHE_TRUSTED_CLOUDFLARE=1 behind Cloudflare: the container finds the real IP by itself, and checks every hop instead of trusting the configuration of the proxies. Describe your setup below to get the recommended configuration.

+

Derrière Traefik, nginx, un ingress Kubernetes ou Cloudflare, Apache et PHP voient l'adresse du proxy, + pas celle de vos utilisateurs. Listez vos proxies dans APACHE_TRUSTED_PROXIES, et définissez + APACHE_TRUSTED_CLOUDFLARE=1 derrière Cloudflare : le conteneur trouve lui-même la vraie IP, et vérifie + chaque hop au lieu de faire confiance à la configuration des proxies. Décrivez votre installation ci-dessous pour + obtenir la configuration recommandée.

-

1Why it matters

+

1Why it mattersPourquoi c'est important

- Doing nothing -

All your users have the IP of the proxy

-
    + Doing nothingNe rien faire +

    All your users have the IP of the proxyTous vos utilisateurs ont l'IP du proxy

    +
    • The logs, the statistics and the audit trails show a single address.
    • A rate limiter or a login throttling blocks all your users at once, or nobody.
    • An IP allowlist of a back-office (Require ip, firewall of the application) lets everybody in: every request comes from the proxy, often from a private address.
    +
      +
    • Les logs, les statistiques et les logs d'audit affichent une seule adresse.
    • +
    • Un rate limiter ou une limitation des tentatives de connexion bloque tous vos utilisateurs d'un coup, ou personne.
    • +
    • Une liste d'IP autorisées d'un back-office (Require ip, pare-feu de l'application) laisse entrer tout le monde : + chaque requête vient du proxy, souvent d'une adresse privée.
    • +
- Trusting the header blindly -

Anyone chooses their IP

-

X-Forwarded-For and CF-Connecting-IP are request headers: any client writes the + Trusting the header blindlyCroire le header sans vérifier +

Anyone chooses their IPN'importe qui choisit son IP

+

X-Forwarded-For and CF-Connecting-IP are request headers: any client writes the value it wants.

+

X-Forwarded-For et CF-Connecting-IP sont des headers de requête : n'importe quel + client y écrit la valeur qu'il veut.

curl -H 'X-Forwarded-For: 10.0.0.1' https://example.com/admin/
-
    +
    • The request passes an allowlist of private addresses, or bypasses a rate limiter with a new address each time, or writes the address of somebody else in your logs.
    • Common causes: trusting every proxy (TRUSTED_PROXIES=REMOTE_ADDR, '*'), or CF-Connecting-IP while the server can be reached without Cloudflare.
    +
      +
    • La requête passe une liste d'adresses privées autorisées, contourne un rate limiter avec une nouvelle adresse à + chaque fois, ou écrit l'adresse de quelqu'un d'autre dans vos logs.
    • +
    • Causes fréquentes : faire confiance à tous les proxies (TRUSTED_PROXIES=REMOTE_ADDR, '*'), ou à + CF-Connecting-IP alors que le serveur est joignable sans Cloudflare.
    • +
-

2Your setup

+

2Your setupVotre installation

Reverse proxy
- - + +
-
Cloudflare in front
+
Cloudflare in frontCloudflare devant
- - + +
-
A DNS-only record (grey cloud) does not go through Cloudflare: answer No.
+
A DNS-only record (grey cloud) does not go through Cloudflare: answer No.Un enregistrement DNS only (nuage gris) ne passe pas par Cloudflare : répondez Non.
Where the proxy runs
- - + +
-
Options (the container stays zero trust either way)
+
Options (the container stays zero trust either way)(le conteneur reste zero trust dans tous les cas)
- -

-
Logs of Apache
+
Logs of ApacheLogs d'Apache
Format
@@ -167,27 +192,29 @@

2Your setup

-
Stored
+
StoredStockage
- - - + + +
Rotation
-
-
-
A new file every day at midnight UTC, and when a file reaches the max size (100M, 1G...). The +
+
+
A new file every day at midnight UTC, and when a file reaches the max size (100M, 1G...). The previous files are gzipped, and deleted after the days kept.
+
Un nouveau fichier chaque jour à minuit UTC, et quand un fichier atteint la taille max (100M, 1G...). + Les fichiers précédents sont compressés en gzip, puis supprimés après les jours conservés.
-
Example line
+
Example lineExemple de ligne
-

3How a request goes through

+

3How a request goes throughLe trajet d'une requête

@@ -200,46 +227,72 @@

4Configuration

-

5Check it

-

Add a temporary ip.php file to your application, then call it from your computer:

+

5Check itVérifiez

+

Add a temporary ip.php file to your application, then call it from your computer:

+

Ajoutez un fichier temporaire ip.php à votre application, puis appelez-le depuis votre ordinateur :

<?php echo $_SERVER['REMOTE_ADDR'], ' ', $_SERVER['HTTPS'] ?? 'off';

-  

The access log of Apache (docker compose logs app, see Logs) shows +

The access log of Apache (docker compose logs app, see Logs) shows the same addresses. Remove ip.php afterwards.

+

Le log d'accès d'Apache (docker compose logs app, voir Logs) affiche + les mêmes adresses. Supprimez ip.php ensuite.

-

6What the container does

+

6What the container doesCe que fait le conteneur

-

It checks every hop

+

It checks every hop

Each proxy adds the address it received the request from at the right of X-Forwarded-For. Apache (mod_remoteip) reads the header from the right, from the address of the connection: it skips the hops added by a trusted proxy, and stops at the first address that is not a trusted proxy: the client. What a client writes at the left of the header is never reached.

Only the proxies you list are trusted: not the private networks, not the other containers of an ingress network shared by several projects.

-

It resolves the names of the proxies

+

Il vérifie chaque hop

+

Chaque proxy ajoute à droite de X-Forwarded-For l'adresse d'où il a reçu la requête. + Apache (mod_remoteip) lit le header depuis la droite, en partant de l'adresse de la connexion : il + ignore les hops ajoutés par un proxy de confiance, et s'arrête à la première adresse qui n'est pas un proxy de + confiance : le client. Ce qu'un client écrit à gauche du header n'est jamais atteint.

+

Seuls les proxies que vous listez sont de confiance : pas les réseaux privés, pas les autres conteneurs d'un réseau + ingress partagé par plusieurs projets.

+

It resolves the names of the proxies

A name (traefik) is resolved by the container at startup, then every 30 seconds: a restarted proxy with a new IP is trusted again within 30 seconds. A name that does not resolve is reported in the logs, and its requests keep the IP of the proxy in the meantime.

-

It keeps the Cloudflare ranges up to date

+

Il résout les noms des proxies

+

Un nom (traefik) est résolu par le conteneur au démarrage, puis toutes les 30 secondes : un proxy + redémarré avec une nouvelle IP redevient de confiance en moins de 30 secondes. Un nom qui ne se résout pas est + signalé dans les logs, et ses requêtes gardent l'IP du proxy en attendant.

+

It keeps the Cloudflare ranges up to date

APACHE_TRUSTED_CLOUDFLARE=1 trusts the ranges published by Cloudflare: downloaded at startup and every day, Apache being reloaded gracefully when they change. Without internet access, the copy shipped in the image is used.

CF-Connecting-IP is only used when the request reached the proxy from a Cloudflare address, even when the proxy replaced X-Forwarded-For (default of Traefik and ingress-nginx): a request sent to the server without Cloudflare cannot use it.

-

It fixes HTTPS too

+

Il tient à jour les plages de Cloudflare

+

APACHE_TRUSTED_CLOUDFLARE=1 fait confiance aux plages + publiées par Cloudflare : téléchargées au démarrage puis chaque jour, Apache étant rechargé en douceur quand + elles changent. Sans accès à internet, la copie livrée dans l'image est utilisée.

+

CF-Connecting-IP n'est utilisé que si la requête est arrivée au proxy depuis une adresse Cloudflare, + même quand le proxy a remplacé X-Forwarded-For (comportement par défaut de Traefik et d'ingress-nginx) : + une requête envoyée au serveur sans Cloudflare ne peut pas s'en servir.

+

It fixes HTTPS too

A request of a trusted proxy with X-Forwarded-Proto: https gets HTTPS=on: PHP generates https:// URLs and secure cookies, as if the container served HTTPS itself.

The access log of Apache, Require ip in a .htaccess and REMOTE_ADDR in PHP all see the client IP.

+

Il corrige aussi HTTPS

+

Une requête d'un proxy de confiance avec X-Forwarded-Proto: https obtient HTTPS=on : PHP + génère des URL https:// et des cookies sécurisés, comme si le conteneur servait lui-même HTTPS.

+

Le log d'accès d'Apache, Require ip dans un .htaccess et REMOTE_ADDR dans + PHP voient tous l'IP du client.

-

7Why not the trusted proxies of Symfony or Laravel

-
    +

    7Why not the trusted proxies of Symfony or LaravelPourquoi pas les trusted proxies de Symfony ou Laravel

    +
    • They only fix PHP: the access log of Apache, Require ip and the other Apache rules keep the IP of the proxy.
    • Their usual configuration trusts too much: TRUSTED_PROXIES=REMOTE_ADDR (Symfony) or @@ -249,80 +302,122 @@

      7Why not the trusted proxies of Symfony or Laravel each application.

    • Each application must do it, and WordPress or an older application has no such setting.
    -

    With APACHE_TRUSTED_PROXIES, REMOTE_ADDR and HTTPS are already right: +

      +
    • Ils ne corrigent que PHP : le log d'accès d'Apache, Require ip et les autres règles Apache + gardent l'IP du proxy.
    • +
    • Leur configuration habituelle fait trop confiance : TRUSTED_PROXIES=REMOTE_ADDR (Symfony) ou + trustProxies(at: '*') (Laravel) fait confiance à quiconque se connecte. Ce n'est sûr que tant que le + conteneur n'est jamais joignable sans le proxy : un port publié ou un réseau partagé, et n'importe qui choisit son IP. + Lister les vrais proxies à la place oblige à suivre les IP des conteneurs et les plages de Cloudflare, dans + chaque application.
    • +
    • Chaque application doit le faire, et WordPress ou une application plus ancienne n'a pas ce paramètre.
    • +
    +

    With APACHE_TRUSTED_PROXIES, REMOTE_ADDR and HTTPS are already right: leave the trusted proxies of the framework empty. Keeping both would be worse than either one: the framework would take the client for a proxy and read the rest of X-Forwarded-For, written by the client.

    +

    Avec APACHE_TRUSTED_PROXIES, REMOTE_ADDR et HTTPS sont déjà corrects : + laissez vides les trusted proxies du framework. Garder les deux serait pire que l'un ou l'autre : le framework + prendrait le client pour un proxy et lirait le reste de X-Forwarded-For, écrit par le client.

8Logs

-

The access log and the error log of Apache show the client IP found by the container. Four variables set them, +

The access log and the error log of Apache show the client IP found by the container. Four variables set them, chosen in Your setup:

+

Le log d'accès et le log d'erreurs d'Apache affichent l'IP du client trouvée par le conteneur. Quatre variables + les règlent, choisies dans Votre installation :

- - + - - - + + +
VariableValues
APACHE_LOG_FORMATcombined (default), detailed (combined + +
VariableValuesValeurs
APACHE_LOG_FORMATcombined (default), detailed (combined + response time in µs + address of the proxy), json, or your own - format, written as is: + format, written as is:combined + (par défaut), detailed (combined + temps de réponse en µs + adresse du proxy), json, ou votre + propre format, écrit tel quel : %a %t "%r" %>s %Dus
APACHE_LOG_OUTPUTstdout (default): the access log on the standard output, - the error log on the standard error. file: files of /var/log/apache2
APACHE_LOG_RETENTION_DAYSWith file: days kept, 14 by - default
APACHE_LOG_MAX_SIZEWith file: a new file when it reaches this size - (100M, 1G), no limit by default
APACHE_LOG_OUTPUTstdout (default): the access log on the standard output, + the error log on the standard error. file: files of /var/log/apache2stdout + (par défaut) : le log d'accès sur la sortie standard, le log d'erreurs sur la sortie d'erreur. file : + fichiers de /var/log/apache2
APACHE_LOG_RETENTION_DAYSWith file: days kept, 14 by + defaultAvec file : jours conservés, 14 par défaut
APACHE_LOG_MAX_SIZEWith file: a new file when it reaches this size + (100M, 1G), no limit by defaultAvec file : un nouveau fichier + quand il atteint cette taille (100M, 1G), pas de limite par défaut
-

stdout: Docker keeps them

-
docker compose logs -f app          # everything
-docker logs app 2>/dev/null          # the access log only
-kubectl logs -f deploy/app           # on Kubernetes
-

A log collector (Loki, Elastic, Datadog...) reads them like the logs of any container. Docker rotates them, but +

stdout: Docker keeps themstdout : Docker les garde

+
docker compose logs -f app          # everythingtout
+docker logs app 2>/dev/null          # the access log onlyle log d'accès seulement
+kubectl logs -f deploy/app           # on Kubernetessur Kubernetes
+

A log collector (Loki, Elastic, Datadog...) reads them like the logs of any container. Docker rotates them, but its default driver, json-file, keeps everything: limit it per service, or for every container in /etc/docker/daemon.json ("log-opts"):

+

Un collecteur de logs (Loki, Elastic, Datadog...) les lit comme les logs de n'importe quel conteneur. Docker + en fait la rotation, mais son driver par défaut, json-file, garde tout : limitez-le par service, ou pour + tous les conteneurs dans /etc/docker/daemon.json ("log-opts") :

    logging:
-      driver: local      # compressed, 5 files of 20 MB by default
+      driver: local      # compressed, 5 files of 20 MB by defaultcompressés, 5 fichiers de 20 Mo par défaut
       options:
         max-size: 50m
         max-file: "5"
-

On Kubernetes, the kubelet rotates them (containerLogMaxSize, 10 MB by default).

-

file: in a directory of the server or a volume

+

On Kubernetes, the kubelet rotates them (containerLogMaxSize, 10 MB by default).

+

Sur Kubernetes, le kubelet en fait la rotation (containerLogMaxSize, 10 Mo par défaut).

+

file: in a directory of the server or a volumefile : dans un répertoire du serveur ou un volume

/var/log/apache2/access.2026-11-13.log
 /var/log/apache2/access.2026-11-12.log.gz
 /var/log/apache2/error.2026-11-13.log
-

One file per day, rotated at midnight UTC by rotatelogs without restarting Apache, the previous +

One file per day, rotated at midnight UTC by rotatelogs without restarting Apache, the previous files gzipped, deleted after APACHE_LOG_RETENTION_DAYS days. With APACHE_LOG_MAX_SIZE, a new file is also started at this size, and the names get the time (access.2026-11-13.143002.log). Mount a directory of the server (./logs:/var/log/apache2) or a volume on /var/log/apache2: without it, the logs are lost with the container.

+

Un fichier par jour, changé à minuit UTC par rotatelogs sans redémarrer Apache, les fichiers + précédents compressés en gzip, supprimés après APACHE_LOG_RETENTION_DAYS jours. Avec + APACHE_LOG_MAX_SIZE, un nouveau fichier démarre aussi à cette taille, et les noms prennent l'heure + (access.2026-11-13.143002.log). Montez un répertoire du serveur (./logs:/var/log/apache2) + ou un volume sur /var/log/apache2 : sans cela, les logs disparaissent avec le conteneur.

docker compose exec app tail -f /var/log/apache2/access.$(date -u +%F).log
 docker compose exec app zgrep ' 500 ' /var/log/apache2/access.*.log.gz
-

With Cloudflare, the logs of Traefik or nginx show the addresses of Cloudflare: the logs of the container are - the reference.

+

With Cloudflare, the logs of Traefik or nginx show the addresses of Cloudflare: the logs of the container are + the reference.

+

Avec Cloudflare, les logs de Traefik ou de nginx affichent les adresses de Cloudflare : les logs du conteneur + font référence.

-

9Fine-tuning and custom setups

-

APACHE_TRUSTED_PROXIES lists the proxies whose X-Forwarded-For hop is trusted, separated +

9Fine-tuning and custom setupsTuning fin et configurations sur mesure

+

APACHE_TRUSTED_PROXIES lists the proxies whose X-Forwarded-For hop is trusted, separated by spaces or commas. APACHE_TRUSTED_CLOUDFLARE=1 adds Cloudflare:

+

APACHE_TRUSTED_PROXIES liste les proxies dont le hop X-Forwarded-For est de confiance, + séparés par des espaces ou des virgules. APACHE_TRUSTED_CLOUDFLARE=1 ajoute Cloudflare :

- - - - - + + + + +
ValueTrusts
APACHE_TRUSTED_PROXIES=traefikA host name: all the addresses it resolves to (all the - replicas of a service), resolved again every 30 seconds
APACHE_TRUSTED_PROXIES=172.18.0.5 10.0.0.0/16IPs or CIDR ranges (IPv4 or IPv6), like - the network of a load balancer
APACHE_TRUSTED_CLOUDFLARE=1The ranges of Cloudflare, updated every day, and its - CF-Connecting-IP header
APACHE_TRUSTED_CLOUDFLARE=onlyThe same, and a 403 for the requests of the proxies - that did not go through Cloudflare (every request but localhost without proxy)
ValueValeurTrustsFait confiance à
APACHE_TRUSTED_PROXIES=traefikA host name: all the addresses it resolves to (all the + replicas of a service), resolved again every 30 secondsUn nom d'hôte : toutes les adresses vers + lesquelles il se résout (tous les réplicas d'un service), résolu à nouveau toutes les 30 secondes
APACHE_TRUSTED_PROXIES=172.18.0.5 10.0.0.0/16IPs or CIDR ranges (IPv4 or IPv6), like + the network of a load balancerDes IP ou des plages CIDR (IPv4 ou IPv6), comme le réseau d'un + load balancer
APACHE_TRUSTED_CLOUDFLARE=1The ranges of Cloudflare, updated every day, and its + CF-Connecting-IP headerLes plages de Cloudflare, mises à jour chaque jour, et son + header CF-Connecting-IP
APACHE_TRUSTED_CLOUDFLARE=onlyThe same, and a 403 for the requests of the proxies + that did not go through Cloudflare (every request but localhost without proxy)La même + chose, et une 403 pour les requêtes des proxies qui ne sont pas passées par Cloudflare (toute requête sauf + localhost sans proxy)
-

The configuration they generate is a good starting point:

+

The configuration they generate is a good starting point:

+

La configuration qu'elles génèrent est un bon point de départ :

docker compose exec app cat /etc/apache2/conf-enabled/docker-trusted-proxies.conf
-

Your own mod_remoteip configuration

-

These variables are a shortcut, not a replacement for +

Your own mod_remoteip configurationVotre propre configuration mod_remoteip

+

These variables are a shortcut, not a replacement for mod_remoteip. For another header, the PROXY protocol or a list of proxies managed elsewhere, leave them empty, enable the modules and mount your own file:

+

Ces variables sont un raccourci, pas un remplacement de + mod_remoteip. Pour un autre header, le protocole + PROXY ou une liste de proxies gérée ailleurs, laissez-les vides, activez les modules et montez votre propre fichier :

services:
   app:
     environment:
@@ -331,52 +426,69 @@ 

Your own mod_remoteip configuration

- ./remoteip.conf:/etc/apache2/conf-enabled/remoteip.conf:ro
# remoteip.conf
 #
-# The header that carries the client IP. X-Forwarded-For is a list ("client, proxy 1, proxy 2"): Apache reads it from
+# The header that carries the client IP. X-Forwarded-For is a list ("client, proxy 1, proxy 2"): Apache reads it from
 # the right and stops at the first address that is not a trusted proxy. A header with a single address (X-Real-IP,
-# True-Client-IP) is only used when the request comes from a trusted proxy.
+# True-Client-IP) is only used when the request comes from a trusted proxy.# Le header qui porte l'IP du client. X-Forwarded-For est une liste ("client, proxy 1, proxy 2") : Apache la lit depuis
+# la droite et s'arrête à la première adresse qui n'est pas un proxy de confiance. Un header à une seule adresse
+# (X-Real-IP, True-Client-IP) n'est utilisé que si la requête vient d'un proxy de confiance.
 RemoteIPHeader X-Real-IP
 
-# Proxies of your network: IPs, CIDR ranges, or host names (resolved once, when Apache starts: prefer the variables
-# above for containers whose IP changes)
+# Proxies of your network: IPs, CIDR ranges, or host names (resolved once, when Apache starts: prefer the variables
+# above for containers whose IP changes)# Proxies de votre réseau : IP, plages CIDR ou noms d'hôte (résolus une seule fois, au démarrage d'Apache : préférez
+# les variables ci-dessus pour les conteneurs dont l'IP change)
 RemoteIPInternalProxy 10.0.0.0/16
 
-# Proxies on the internet (a CDN): same, but a private address they forward is not accepted as the client IP
+# Proxies on the internet (a CDN): same, but a private address they forward is not accepted as the client IP# Proxies sur internet (un CDN) : idem, mais une adresse privée qu'ils transmettent n'est pas acceptée comme IP du client
 RemoteIPTrustedProxy 203.0.113.0/24
 
-# Or a file of addresses, one per line, that you keep up to date (reloaded with apache2ctl graceful)
+# Or a file of addresses, one per line, that you keep up to date (reloaded with apache2ctl graceful)# Ou un fichier d'adresses, une par ligne, que vous tenez à jour (rechargé avec apache2ctl graceful)
 #RemoteIPTrustedProxyList /etc/apache2/cdn-ips.txt
 
-# PROXY protocol (HAProxy, AWS NLB): the address comes from the connection itself, no header is used. Every
-# connection must then use it, except the ones of the listed addresses (the health checks of Docker for instance).
+# PROXY protocol (HAProxy, AWS NLB): the address comes from the connection itself, no header is used. Every
+# connection must then use it, except the ones of the listed addresses (the health checks of Docker for instance).# Protocole PROXY (HAProxy, AWS NLB) : l'adresse vient de la connexion elle-même, aucun header n'est utilisé. Toutes
+# les connexions doivent alors l'utiliser, sauf celles des adresses listées (les health checks de Docker par exemple).
 #RemoteIPProxyProtocol On
 #RemoteIPProxyProtocolExceptions 127.0.0.1
 
-# HTTPS=on for PHP, only when the request comes from the proxy: a SetEnvIf on X-Forwarded-Proto alone would let any
-# client set it
+# HTTPS=on for PHP, only when the request comes from the proxy: a SetEnvIf on X-Forwarded-Proto alone would let any
+# client set it# HTTPS=on pour PHP, seulement quand la requête vient du proxy : un SetEnvIf sur X-Forwarded-Proto seul laisserait
+# n'importe quel client le définir
 <If "%{HTTP:X-Forwarded-Proto} == 'https' && %{CONN_REMOTE_ADDR} -ipmatch '10.0.0.0/16'">
     SetEnv HTTPS on
 </If>
-

Check it with docker compose exec app apache2ctl configtest, then with ip.php +

Check it with docker compose exec app apache2ctl configtest, then with ip.php (Check it). headers is only needed for RequestHeader directives.

+

Vérifiez-la avec docker compose exec app apache2ctl configtest, puis avec ip.php + (Vérifiez). headers n'est nécessaire que pour les directives RequestHeader.

-

The fpm variant behind your own nginx

-

Without its built-in Apache, PHP-FPM receives the client IP from nginx: use its +

The fpm variant behind your own nginxLa variante fpm derrière votre propre nginx

+

Without its built-in Apache, PHP-FPM receives the client IP from nginx: use its real IP module (set_real_ip_from with the address of the proxy in front of it, real_ip_header X-Forwarded-For, real_ip_recursive on).

+

Sans son Apache intégré, PHP-FPM reçoit l'IP du client de nginx : utilisez son + module real IP + (set_real_ip_from avec l'adresse du proxy placé devant lui, real_ip_header + X-Forwarded-For, real_ip_recursive on).

{% raw %}