From 51ad57f6fda6e9095899dfd49d2af9801898abbf Mon Sep 17 00:00:00 2001 From: Mistral OZ - MIO Date: Fri, 4 Dec 2026 19:57:33 +0100 Subject: [PATCH 1/6] Documentation site in English and French English stays the default; a switch in the header opens the French version. - Markdown pages: the French translation sits in docs/fr/ under the same name, with the English anchors kept on its headings so that the links to a section work in both languages. - Interactive pages (tuning, reverse proxy, debugging): both languages in the same file, French with #lang=fr. - The menu, the page titles and descriptions follow the language. The README, the licence, the changelog and the other files of the repository stay in English. Environment variables, directives, code and commands are not translated. --- docs/_config.yml | 6 + docs/_data/nav.yml | 20 ++ docs/_layouts/default.html | 79 ++++- docs/assets/css/site.css | 7 +- docs/contributing.md | 4 +- docs/debugging/index.html | 11 +- docs/fr/advanced.md | 144 ++++++++++ docs/fr/contributing.md | 78 +++++ docs/fr/extensions.md | 104 +++++++ docs/fr/fpm.md | 227 +++++++++++++++ docs/fr/index.md | 29 ++ docs/fr/php-configuration.md | 36 +++ docs/fr/processes.md | 117 ++++++++ docs/fr/security.md | 87 ++++++ docs/fr/variants.md | 231 +++++++++++++++ docs/reverse-proxy/index.html | 527 ++++++++++++++++++++++------------ docs/tuning/index.html | 502 ++++++++++++++++++++------------ 17 files changed, 1814 insertions(+), 395 deletions(-) create mode 100644 docs/fr/advanced.md create mode 100644 docs/fr/contributing.md create mode 100644 docs/fr/extensions.md create mode 100644 docs/fr/fpm.md create mode 100644 docs/fr/index.md create mode 100644 docs/fr/php-configuration.md create mode 100644 docs/fr/processes.md create mode 100644 docs/fr/security.md create mode 100644 docs/fr/variants.md 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..9b68f47 100644 --- a/docs/_data/nav.yml +++ b/docs/_data/nav.yml @@ -1,32 +1,52 @@ +# 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_fr: Servir et dimensionner items: - title: Serving with the fpm variant + title_fr: Servir avec la variante fpm url: /fpm.html - title: Tuning simulator + title_fr: Simulateur de réglages 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, démons url: /processes.html - title: Debugging, profiling, coverage + title_fr: Débogage, profilage, couverture 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..169af96 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -1,30 +1,66 @@ - +{%- 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 + {%- if page.bilingual %} + thecodingmachine/php + thecodingmachine/php + v5 documentationdocumentation v5 + {%- else %} + thecodingmachine/php + {% if lang == 'fr' %}documentation v5{% else %}v5 documentation{% endif %} + {%- endif %} + GitHub
@@ -37,6 +73,27 @@

{{ section.title }}

diff --git a/docs/assets/css/site.css b/docs/assets/css/site.css index 7597a96..a20d1b5 100644 --- a/docs/assets/css/site.css +++ b/docs/assets/css/site.css @@ -32,7 +32,12 @@ 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; } +header.site .langs { margin-left: auto; display: flex; gap: 2px; font-size: 13px; } +header.site .langs a { padding: 2px 8px; border-radius: 6px; color: var(--muted); text-decoration: none; } +header.site .langs a[aria-current] { background: var(--soft); color: var(--accent); font-weight: 600; } +header.site .repo { font-size: 14px; } +/* 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; } .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; } diff --git a/docs/contributing.md b/docs/contributing.md index 60fcad4..924bad5 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: 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`): diff --git a/docs/debugging/index.html b/docs/debugging/index.html index 1bcf7d2..378c013 100644 --- a/docs/debugging/index.html +++ b/docs/debugging/index.html @@ -1,8 +1,11 @@ --- layout: default title: Debugging, profiling, coverage +title_fr: Débogage, profilage, couverture +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

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.

@@ -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/fr/advanced.md b/docs/fr/advanced.md new file mode 100644 index 0000000..f3479fc --- /dev/null +++ b/docs/fr/advanced.md @@ -0,0 +1,144 @@ +# 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. + +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.4-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.4-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.4-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.4-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.4-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.4-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 +réglage 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 réglez jamais cette option à `false` : + +```yml +apiVersion: v1 +kind: Pod +# ... +spec: + containers: + - name: foobar + image: thecodingmachine/php:8.4-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..85ac5ef --- /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 : 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.4 +``` + +`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.4 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.4 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` : les listes de versions de la section « Images » +- `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..a9e53c8 --- /dev/null +++ b/docs/fr/extensions.md @@ -0,0 +1,104 @@ +# 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.4-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.4-v5-cli php -m` + +**Remarques :** + +- *ev* n'est pas disponible en PHP 8.1+ +- *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 déboguer, profiler ou mesurer la couverture (*xdebug*, *pcov*, *excimer*, *xhprof*, *spx*, *blackfire*, *opentelemetry*), voir [Débogage, profilage, couverture](../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.4-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.4-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.4-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.4-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..5c8370f --- /dev/null +++ b/docs/fr/fpm.md @@ -0,0 +1,227 @@ +# Servir 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 servir 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.4-v5-fpm +``` + +```yml +services: + app: + image: thecodingmachine/php:8.4-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 réglages +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.4-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… Réglez 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.4-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 +réglages : 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.4-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 + - ./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`. Dimensionnez 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 réglages](../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 file de messages. + +### `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`). +- L'en-tête `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 journal 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.4-v5-apache` devient + `thecodingmachine/php:8.4-v5-fpm` avec `PHP_FPM_WEB_SERVER=apache`. Gardez vos variables `APACHE_*`. +2. Réglez le nombre de workers PHP (`PHP_FPM_PM_MAX_CHILDREN`) selon votre trafic et votre mémoire (voir plus haut, + ou le [simulateur de réglages](../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 sonde (Kubernetes). diff --git a/docs/fr/index.md b/docs/fr/index.md new file mode 100644 index 0000000..9ddbaf7 --- /dev/null +++ b/docs/fr/index.md @@ -0,0 +1,29 @@ +# Documentation de thecodingmachine/php + +Des images PHP généralistes pour Docker : variantes *cli*, *apache* et *fpm*, images slim et fat, configurées par des +variables d'environnement. La liste des images et le démarrage rapide sont dans le +[README](https://github.com/thecodingmachine/docker-images-php#readme) (en anglais). + +## Choisir et dimensionner {#choose-and-size} + +- [Simulateur de réglages](../tuning/#lang=fr) : choisissez votre type d'application et votre nombre d'utilisateurs, + obtenez la variante à utiliser et ses réglages. +- [Variantes](variants.md) : *cli*, *apache* (racine web, ports, modules, connexions) et *fpm*. +- [Servir avec la variante fpm](fpm.md) : Apache intégré ou votre propre serveur web, contraintes de PHP-FPM, migration + depuis la variante *apache*. + +## Configurer {#configure} + +- [Extensions PHP](extensions.md) +- [Configuration de PHP (php.ini)](php-configuration.md) +- [Processus : commandes de démarrage, tâches cron et démons](processes.md) +- [Débogage, profilage, couverture](../debugging/#lang=fr) : à partir de vos besoins, les outils à charger en développement, en CI et en production, et la configuration de votre IDE, de votre agent IA et de chaque environnement +- [Fonctions avancées](advanced.md) + +## Projet {#project} + +- [Sécurité](security.md) +- [Contribuer](contributing.md) + +À venir avec la v6 : une variante [FrankenPHP](https://frankenphp.dev/), déjà présente dans le +[simulateur de réglages](../tuning/#lang=fr). diff --git a/docs/fr/php-configuration.md b/docs/fr/php-configuration.md new file mode 100644 index 0000000..261f0d2 --- /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.4/php.ini-development) +fourni avec PHP. La variable `TEMPLATE_PHP_INI` choisit plutôt celui de *production* : + +```bash +TEMPLATE_PHP_INI=production +``` + +## Régler les paramètres de php.ini {#setting-phpini-parameters} + +Les variables d'environnement `PHP_INI_` règlent n'importe quel paramètre de `php.ini` : + +```yml +services: + my_app: + image: thecodingmachine/php:8.4-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..3adf3da --- /dev/null +++ b/docs/fr/processes.md @@ -0,0 +1,117 @@ +# Processus : commandes de démarrage, tâches cron et démons + +À 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 [démons](#daemons) s'il y en a. + +## 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.4-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.4-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 [démons](#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é. + +## Démons {#daemons} + +**Préférez un conteneur par processus.** Par exemple, lancez un worker de file 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 +démon : 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 démons et +Supercronic) reçoivent `SIGTERM`. diff --git a/docs/fr/security.md b/docs/fr/security.md new file mode 100644 index 0000000..80f59c2 --- /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.4-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..7bcf1bb --- /dev/null +++ b/docs/fr/variants.md @@ -0,0 +1,231 @@ +# 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. + +## 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.4-v5-cli + +CMD ["php", "myprogram.php", "some_param"] +``` + +```yml +services: + my_app: + image: thecodingmachine/php:8.4-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 servir 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 [Servir avec 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.4-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.4-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 dimensionnez `APACHE_MAX_REQUEST_WORKERS` selon la mémoire du conteneur (150 processus de +100 Mo demandent 15 Go). + +Le [simulateur de réglages](../tuning/#lang=fr) choisit ces réglages (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 réglez +`APACHE_TRUSTED_CLOUDFLARE=1` derrière Cloudflare : Apache et PHP obtiennent l'IP des utilisateurs (`REMOTE_ADDR`, +journal 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 en-tête `X-Forwarded-For` ou `CF-Connecting-IP` falsifié est ignoré. + +```yml +services: + app: + image: thecodingmachine/php:8.4-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. + +### Journaux {#logs} + +Le journal d'accès va sur la sortie standard du conteneur et le journal d'erreurs sur sa sortie d'erreur +(`docker compose logs app`). `APACHE_LOG_FORMAT` choisit le format du journal 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 journaux sont perdus avec le conteneur. + +```yml +services: + app: + image: thecodingmachine/php:8.4-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.4-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.4-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 règle indépendamment (voir +[Réglages 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.4-v5-fpm +``` + +[Servir 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*. + +### Réglages 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 | Réglage 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.4-v5-fpm + healthcheck: + test: ["CMD", "php-fpm-healthcheck"] +``` diff --git a/docs/reverse-proxy/index.html b/docs/reverse-proxy/index.html index 67b3484..c2a6c28 100644 --- a/docs/reverse-proxy/index.html +++ b/docs/reverse-proxy/index.html @@ -1,8 +1,11 @@ --- 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 en-têtes 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 saut 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 journaux 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 l'en-tête 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 en-têtes 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 saut

+

Chaque proxy ajoute à droite de X-Forwarded-For l'adresse d'où il a reçu la requête. + Apache (mod_remoteip) lit l'en-tête depuis la droite, en partant de l'adresse de la connexion : il + saute les sauts 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 de l'en-tête 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 réglage.
    • +
    +

    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 setupsRéglages fins et installations 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 saut 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 + en-tête 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 en-tête, 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,45 +426,62 @@ 

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.# L'en-tête 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 en-tête à 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 en-tête 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 %} +{%- if page.name == 'images.md' %} + +{%- endif %} diff --git a/docs/assets/css/site.css b/docs/assets/css/site.css index bdca6e8..d50aa9f 100644 --- a/docs/assets/css/site.css +++ b/docs/assets/css/site.css @@ -119,6 +119,35 @@ button.copy.copied { opacity: 1; border-color: var(--mint); background-image: ur .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; } diff --git a/docs/assets/img/images.fr.svg b/docs/assets/img/images.fr.svg index bb767cd..64dd432 100644 --- a/docs/assets/img/images.fr.svg +++ b/docs/assets/img/images.fr.svg @@ -3,6 +3,6 @@ .t{fill:#0a1628;font:600 14px 'Open Sans',system-ui,sans-serif}.s{fill:#5b6474;font:400 12.5px 'Open Sans',system-ui,sans-serif} .m{fill:#0a1628;font:500 12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mw{fill:#ffffff;font:600 13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace} .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} -.hl{fill:#e3fbf3;stroke:#00c48f} -@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}} -cliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composerextensions de base8.4-v5-slim-cli8.4-v5-slim-apache8.4-v5-slim-fpmfat+ extensions courantes+ Supercronic, locales8.4-v5-cli8.4-v5-apache8.4-v5-fpmnode+ NodeJSnpm, yarn8.4-v5-cli-node248.4-v5-apache-node248.4-v5-fpm-node24 +.hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} +@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} +cliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composerextensions de base8.4-v5-slim-cli8.4-v5-slim-apache8.4-v5-slim-fpmfat+ extensions courantes+ Supercronic, locales8.4-v5-cli8.4-v5-apache8.4-v5-fpmnode+ NodeJSnpm, yarn8.4-v5-cli-node248.4-v5-apache-node248.4-v5-fpm-node24 diff --git a/docs/assets/img/images.svg b/docs/assets/img/images.svg index 2d7e129..d51f662 100644 --- a/docs/assets/img/images.svg +++ b/docs/assets/img/images.svg @@ -3,6 +3,6 @@ .t{fill:#0a1628;font:600 14px 'Open Sans',system-ui,sans-serif}.s{fill:#5b6474;font:400 12.5px 'Open Sans',system-ui,sans-serif} .m{fill:#0a1628;font:500 12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mw{fill:#ffffff;font:600 13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace} .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} -.hl{fill:#e3fbf3;stroke:#00c48f} -@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}} -cliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composercore extensions8.4-v5-slim-cli8.4-v5-slim-apache8.4-v5-slim-fpmfat+ common extensions+ Supercronic, locales8.4-v5-cli8.4-v5-apache8.4-v5-fpmnode+ NodeJSnpm, yarn8.4-v5-cli-node248.4-v5-apache-node248.4-v5-fpm-node24 +.hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} +@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} +cliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composercore extensions8.4-v5-slim-cli8.4-v5-slim-apache8.4-v5-slim-fpmfat+ common extensions+ Supercronic, locales8.4-v5-cli8.4-v5-apache8.4-v5-fpmnode+ NodeJSnpm, yarn8.4-v5-cli-node248.4-v5-apache-node248.4-v5-fpm-node24 diff --git a/docs/assets/img/permissions.fr.svg b/docs/assets/img/permissions.fr.svg index d5cb6db..fc5b563 100644 --- a/docs/assets/img/permissions.fr.svg +++ b/docs/assets/img/permissions.fr.svg @@ -3,6 +3,6 @@ .t{fill:#0a1628;font:600 14px 'Open Sans',system-ui,sans-serif}.s{fill:#5b6474;font:400 12.5px 'Open Sans',system-ui,sans-serif} .m{fill:#0a1628;font:500 12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mw{fill:#ffffff;font:600 13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace} .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} -.hl{fill:#e3fbf3;stroke:#00c48f} -@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}} +.hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} +@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} VOTRE 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 index 17c0d58..57bbb0d 100644 --- a/docs/assets/img/permissions.svg +++ b/docs/assets/img/permissions.svg @@ -3,6 +3,6 @@ .t{fill:#0a1628;font:600 14px 'Open Sans',system-ui,sans-serif}.s{fill:#5b6474;font:400 12.5px 'Open Sans',system-ui,sans-serif} .m{fill:#0a1628;font:500 12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mw{fill:#ffffff;font:600 13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace} .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} -.hl{fill:#e3fbf3;stroke:#00c48f} -@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}} +.hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} +@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} YOUR 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 index 6a52124..91299b0 100644 --- a/docs/assets/img/processes.fr.svg +++ b/docs/assets/img/processes.fr.svg @@ -3,6 +3,6 @@ .t{fill:#0a1628;font:600 14px 'Open Sans',system-ui,sans-serif}.s{fill:#5b6474;font:400 12.5px 'Open Sans',system-ui,sans-serif} .m{fill:#0a1628;font:500 12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mw{fill:#ffffff;font:600 13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace} .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} -.hl{fill:#e3fbf3;stroke:#00c48f} -@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}} +.hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} +@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} docker 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 index cf0f44a..522c96f 100644 --- a/docs/assets/img/processes.svg +++ b/docs/assets/img/processes.svg @@ -3,6 +3,6 @@ .t{fill:#0a1628;font:600 14px 'Open Sans',system-ui,sans-serif}.s{fill:#5b6474;font:400 12.5px 'Open Sans',system-ui,sans-serif} .m{fill:#0a1628;font:500 12.5px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}.mw{fill:#ffffff;font:600 13px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace} .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} -.hl{fill:#e3fbf3;stroke:#00c48f} -@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}} +.hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} +@media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} docker 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/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/fr/images.md b/docs/fr/images.md index de9b013..bc6e66c 100644 --- a/docs/fr/images.md +++ b/docs/fr/images.md @@ -11,7 +11,87 @@ Voir les [variantes](variants.md) pour choisir entre *cli*, *apache* et *fpm*, e [versions maintenues](https://github.com/thecodingmachine/docker-images-php#supported-versions) (en anglais). -## apache +
+## 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.4-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.4-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.4-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.4-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 | |-----|-----|------|--------| @@ -22,7 +102,7 @@ Voir les [variantes](variants.md) pour choisir entre *cli*, *apache* et *fpm*, e | 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 +### fpm | PHP | fat | slim | NodeJS | |-----|-----|------|--------| @@ -33,7 +113,7 @@ Voir les [variantes](variants.md) pour choisir entre *cli*, *apache* et *fpm*, e | 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 +### cli | PHP | fat | slim | NodeJS | |-----|-----|------|--------| diff --git a/docs/images.md b/docs/images.md index 2df743f..6ba90eb 100644 --- a/docs/images.md +++ b/docs/images.md @@ -11,7 +11,86 @@ See the [variants](variants.md) to choose between *cli*, *apache* and *fpm*, and [supported versions](https://github.com/thecodingmachine/docker-images-php#supported-versions). -## apache +
+## 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.4-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.4-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.4-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.4-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 | |-----|-----|------|--------| @@ -22,7 +101,7 @@ See the [variants](variants.md) to choose between *cli*, *apache* and *fpm*, and | 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 +### fpm | PHP | fat | slim | NodeJS | |-----|-----|------|--------| @@ -33,7 +112,7 @@ See the [variants](variants.md) to choose between *cli*, *apache* and *fpm*, and | 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 +### cli | PHP | fat | slim | NodeJS | |-----|-----|------|--------| diff --git a/utils/README.blueprint.md b/utils/README.blueprint.md index 5e90ef7..bd62e0f 100644 --- a/utils/README.blueprint.md +++ b/utils/README.blueprint.md @@ -28,10 +28,21 @@ See the [documentation](#documentation) for all the features. {{ $image := .Orbit.Images }} ## Images -The images are `thecodingmachine/php:-v5-[slim-][-node]`, e.g. -`thecodingmachine/php:{{ $image.php_version }}-v5-apache` or `thecodingmachine/php:{{ $image.php_version }}-v5-fpm-node{{ $image.node_version }}`. -The [list of the images](https://thecodingmachine.github.io/docker-images-php/images.html) gives every tag, one click to copy it -(also [on GitHub](docs/images.md)). +The main images, for PHP {{ $image.php_version }}: + +| Use | Image | +|--------------------------------------------------------------|----------------------------------------------------------------| +| Web application: Apache + `mod_php` | `thecodingmachine/php:{{ $image.php_version }}-v5-apache` | +| Web application: PHP-FPM (see [the fpm variant](docs/fpm.md)) | `thecodingmachine/php:{{ $image.php_version }}-v5-fpm` | +| CLI: scripts, workers, CI | `thecodingmachine/php:{{ $image.php_version }}-v5-cli` | +| With NodeJS {{ $image.node_version }}, to build your assets | `thecodingmachine/php:{{ $image.php_version }}-v5-apache-node{{ $image.node_version }}` | +| Production (*slim*): only the extensions listed at build time | `thecodingmachine/php:{{ $image.php_version }}-v5-slim-apache` | + +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 diff --git a/utils/images.blueprint.md b/utils/images.blueprint.md index 3747565..bf7df84 100644 --- a/utils/images.blueprint.md +++ b/utils/images.blueprint.md @@ -1,4 +1,4 @@ -{{ $fr := eq .Orbit.lang "fr" }}{{ $image := .Orbit.Images }}{{ $versions := list "8.6" "8.5" "8.4" "8.3" "8.2" "8.1" }}{{ $nodeVersions := list "22" "24" "26" }}{{ $legacyVersions := list "8.1" }}{{ $legacyNodeVersions := list "20" "22" "24" "26" }}{{ if $fr }}# Images +{{ $fr := eq .Orbit.lang "fr" }}{{ $image := .Orbit.Images }}{{ $versions := list "8.6" "8.5" "8.4" "8.3" "8.2" "8.1" }}{{ $nodeVersions := list "22" "24" "26" }}{{ $legacyVersions := list "8.1" }}{{ $legacyNodeVersions := list "20" "22" "24" "26" }}{{ $otherNodeVersions := list "16" "18" "20" }}{{ if $fr }}# 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]` : @@ -21,8 +21,164 @@ All the images are published on [Docker Hub](https://hub.docker.com/r/thecodingm 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). {{ end }} + +
+{{ if $fr }}## 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={{ $image.node_version }} +FROM thecodingmachine/php:{{ $image.php_version }}-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:{{ $image.php_version }}-v5-apache-node{{ $image.node_version }} + +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:{{ $image.php_version }}-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:{{ $image.php_version }}-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). + +{{ else }}## 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={{ $image.node_version }} +FROM thecodingmachine/php:{{ $image.php_version }}-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:{{ $image.php_version }}-v5-apache-node{{ $image.node_version }} + +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:{{ $image.php_version }}-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:{{ $image.php_version }}-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). + +{{ end }}{{ if $fr }}## Tous les tags {#all-the-tags}{{ else }}## All the tags{{ end }} {{ range $variant := list "apache" "fpm" "cli" }} -## {{ $variant }} +### {{ $variant }} | PHP | fat | slim | NodeJS | |-----|-----|------|--------| From 8ad713e1fea16af6cc864de571d0b00f8e4a279f Mon Sep 17 00:00:00 2001 From: Mistral OZ - MIO Date: Sat, 5 Dec 2026 00:05:57 +0100 Subject: [PATCH 5/6] Examples on the latest PHP version, 8.6 The README, the Images page and the picker take the version of orbit-images.yml, now 8.6; the examples of the documentation pages, the diagrams and the interactive pages use 8.6 as well. --- README.md | 22 +++++++++++----------- docs/advanced.md | 14 +++++++------- docs/assets/img/images.fr.svg | 2 +- docs/assets/img/images.svg | 2 +- docs/contributing.md | 6 +++--- docs/debugging/index.html | 2 +- docs/extensions.md | 12 ++++++------ docs/fpm.md | 16 ++++++++-------- docs/fr/advanced.md | 14 +++++++------- docs/fr/contributing.md | 6 +++--- docs/fr/extensions.md | 12 ++++++------ docs/fr/fpm.md | 16 ++++++++-------- docs/fr/images.md | 14 +++++++------- docs/fr/index.md | 4 ++-- docs/fr/php-configuration.md | 4 ++-- docs/fr/processes.md | 4 ++-- docs/fr/security.md | 2 +- docs/fr/variants.md | 20 ++++++++++---------- docs/images.md | 14 +++++++------- docs/index.md | 4 ++-- docs/php-configuration.md | 4 ++-- docs/processes.md | 4 ++-- docs/reverse-proxy/index.html | 2 +- docs/security.md | 2 +- docs/tuning/index.html | 6 +++--- docs/variants.md | 20 ++++++++++---------- orbit-images.yml | 2 +- 27 files changed, 115 insertions(+), 115 deletions(-) diff --git a/README.md b/README.md index 5965b78..749c0d2 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,15 @@ See the [documentation](#documentation) for all the features. ## Images -The main images, for PHP 8.4: +The main images, for PHP 8.6: | Use | Image | |--------------------------------------------------------------|----------------------------------------------------------------| -| Web application: Apache + `mod_php` | `thecodingmachine/php:8.4-v5-apache` | -| Web application: PHP-FPM (see [the fpm variant](docs/fpm.md)) | `thecodingmachine/php:8.4-v5-fpm` | -| CLI: scripts, workers, CI | `thecodingmachine/php:8.4-v5-cli` | -| With NodeJS 24, to build your assets | `thecodingmachine/php:8.4-v5-apache-node24` | -| Production (*slim*): only the extensions listed at build time | `thecodingmachine/php:8.4-v5-slim-apache` | +| 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` | 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; @@ -80,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 diff --git a/docs/advanced.md b/docs/advanced.md index cc54f43..19b346b 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -33,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. @@ -62,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 @@ -81,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 @@ -94,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 ``` @@ -102,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 @@ -136,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/img/images.fr.svg b/docs/assets/img/images.fr.svg index 64dd432..1744017 100644 --- a/docs/assets/img/images.fr.svg +++ b/docs/assets/img/images.fr.svg @@ -5,4 +5,4 @@ .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} .hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} @media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} -cliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composerextensions de base8.4-v5-slim-cli8.4-v5-slim-apache8.4-v5-slim-fpmfat+ extensions courantes+ Supercronic, locales8.4-v5-cli8.4-v5-apache8.4-v5-fpmnode+ NodeJSnpm, yarn8.4-v5-cli-node248.4-v5-apache-node248.4-v5-fpm-node24 +cliphp -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 index d51f662..52405c6 100644 --- a/docs/assets/img/images.svg +++ b/docs/assets/img/images.svg @@ -5,4 +5,4 @@ .lbl{fill:#00805f;font:700 11px 'Open Sans',system-ui,sans-serif;letter-spacing:.08em}.ar{stroke:#8a96a8;stroke-width:1.6;fill:none}.arh{fill:#8a96a8} .hl{fill:#e3fbf3;stroke:#00c48f}.hds{fill:#b9c7d6;font:500 12px 'Open Sans',system-ui,sans-serif} @media (prefers-color-scheme:dark){.bg{fill:#111a2b}.box{fill:#19243a;stroke:#2b3954}.t,.m{fill:#e6e9ee}.s{fill:#9aa6b8}.lbl{fill:#2fe0ad}.hl{fill:#123a33;stroke:#2fe0ad}.hd{fill:#00ecae}.hdt,.mw{fill:#06281f}.hds{fill:#0b3d30}} -cliphp -vapache:80 HTTPfpm:9000 FastCGIslimPHP, Composercore extensions8.4-v5-slim-cli8.4-v5-slim-apache8.4-v5-slim-fpmfat+ common extensions+ Supercronic, locales8.4-v5-cli8.4-v5-apache8.4-v5-fpmnode+ NodeJSnpm, yarn8.4-v5-cli-node248.4-v5-apache-node248.4-v5-fpm-node24 +cliphp -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/contributing.md b/docs/contributing.md index 1cb44c5..f03d8c3 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -36,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. @@ -44,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 diff --git a/docs/debugging/index.html b/docs/debugging/index.html index b837760..f1ebe8f 100644 --- a/docs/debugging/index.html +++ b/docs/debugging/index.html @@ -547,7 +547,7 @@

4Configuration ``).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); 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 index 3ab01a7..f8adb0d 100644 --- a/docs/fr/advanced.md +++ b/docs/fr/advanced.md @@ -34,14 +34,14 @@ les changer par une faille de sécurité, il peut exécuter n'importe quel code ## NodeJS {#nodejs} -Les images fat ont des variantes NodeJS (par ex. `thecodingmachine/php:8.4-v5-apache-node24`), voir la +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.4-v5-slim-apache +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. @@ -63,7 +63,7 @@ plutôt pendant le build, avec un ARG avant le `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 {#locales} @@ -82,7 +82,7 @@ ARG avant le `FROM` : ```Dockerfile ARG INSTALL_LOCALES=1 -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ``` ## Clés privées SSH {#ssh-private-keys} @@ -95,7 +95,7 @@ Si votre projet dépend d'un [paquet stocké dans un dépôt Git privé](https:/ ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache volumes: - ~/.ssh:/home/docker/.ssh ``` @@ -103,7 +103,7 @@ services: **Dans un Dockerfile**, passez la clé et la signature du serveur (`ssh-keyscan myserver.com`) en arguments de build : ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache +FROM thecodingmachine/php:8.6-v5-apache ARG SSH_PRIVATE_KEY ARG SSH_KNOWN_HOSTS @@ -138,7 +138,7 @@ kind: Pod spec: containers: - name: foobar - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache securityContext: allowPrivilegeEscalation: true # n'utilisez jamais "false" ici ``` diff --git a/docs/fr/contributing.md b/docs/fr/contributing.md index 8cf28ca..7bfc040 100644 --- a/docs/fr/contributing.md +++ b/docs/fr/contributing.md @@ -39,7 +39,7 @@ Les tests utilisent [bash_unit](https://github.com/pgrange/bash_unit) (voir la *apache* et *fpm*) : ```bash -$ make test-8.4 +$ make test-8.6 ``` `make test-quick` construit et teste la variante *cli* des versions de PHP maintenues, sans NodeJS. @@ -47,14 +47,14 @@ $ make test-8.4 Pour tester des images déjà construites, lancez directement la suite de tests : ```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 ``` 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.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 ``` Les variables de [`tests-suite/config`](../../tests-suite/config) choisissent les images à tester, par ex. diff --git a/docs/fr/extensions.md b/docs/fr/extensions.md index ef6007e..0a42c21 100644 --- a/docs/fr/extensions.md +++ b/docs/fr/extensions.md @@ -14,7 +14,7 @@ Ces extensions sont activées par défaut dans les images slim : `calendar` `cty `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.4-v5-slim-cli php -m` +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} @@ -27,7 +27,7 @@ Cette liste peut être obsolète, vous pouvez la vérifier avec : `docker run -- `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.4-v5-cli php -m` +Cette liste peut être obsolète, vous pouvez la vérifier avec : `docker run --rm thecodingmachine/php:8.6-v5-cli php -m` **Remarques :** @@ -48,7 +48,7 @@ Utilisez les variables d'environnement `PHP_EXTENSION_` : ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache environment: # Active l'extension PostgreSQL PHP_EXTENSION_PGSQL: 1 @@ -68,7 +68,7 @@ Avec une image slim, l'ARG `PHP_EXTENSIONS` liste les extensions à installer pe ```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 # Le build télécharge et compile automatiquement les extensions # (grâce à un hook ONBUILD de l'image slim) ``` @@ -84,7 +84,7 @@ Attention : # L'ARG PHP_EXTENSIONS s'applique à l'image slim 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 &&\ @@ -92,7 +92,7 @@ RUN composer install &&\ yarn build # L'image slim compile les extensions listées tout en haut du fichier -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/fr/fpm.md b/docs/fr/fpm.md index 687037d..cccad20 100644 --- a/docs/fr/fpm.md +++ b/docs/fr/fpm.md @@ -9,13 +9,13 @@ La variante *fpm* fait tourner [PHP-FPM](https://www.php.net/manual/fr/install.f ## 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.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: @@ -65,7 +65,7 @@ ont besoin des fichiers de l'application. Exemple avec nginx : ```yml services: php: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm volumes: - .:/var/www/html web: @@ -107,7 +107,7 @@ travail : par défaut, les commandes tournent avec le propriétaire du répertoi ```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 @@ -151,12 +151,12 @@ Avec l'Apache intégré, envoyez les requêtes du back-office à ce 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 ``` @@ -219,8 +219,8 @@ répond par une erreur `500`. Utilisez les variables d'environnement `PHP_INI_*` ## Migrer depuis la variante apache {#migrating-from-the-apache-variant} -1. Utilisez l'image *fpm* et activez l'Apache intégré : `thecodingmachine/php:8.4-v5-apache` devient - `thecodingmachine/php:8.4-v5-fpm` avec `PHP_FPM_WEB_SERVER=apache`. Gardez vos variables `APACHE_*`. +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`. diff --git a/docs/fr/images.md b/docs/fr/images.md index bc6e66c..206be44 100644 --- a/docs/fr/images.md +++ b/docs/fr/images.md @@ -11,7 +11,7 @@ Voir les [variantes](variants.md) pour choisir entre *cli*, *apache* et *fpm*, e [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 @@ -27,7 +27,7 @@ Les ARG écrits **avant** le `FROM` sont lus par l'image slim pendant le build : ```Dockerfile ARG PHP_EXTENSIONS="apcu intl pdo_mysql" ARG NODE_VERSION=24 -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ENV TEMPLATE_PHP_INI=production @@ -43,7 +43,7 @@ Les extensions s'activent avec `PHP_EXTENSION_=1` (voir [Extensions](extens tags `-node`. ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache-node24 +FROM thecodingmachine/php:8.6-v5-apache-node24 ENV TEMPLATE_PHP_INI=production \ PHP_EXTENSION_INTL=1 @@ -59,7 +59,7 @@ l'image fat sans NodeJS et installez-le depuis NodeSource ; à partir de NodeJS `sudo npm install -g corepack` avant `corepack enable` : ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache +FROM thecodingmachine/php:8.6-v5-apache RUN sudo apt-get update \ && sudo apt-get install -y --no-install-recommends gnupg \ @@ -79,7 +79,7 @@ En développement, avec l'image fat et votre projet monté : ```yml services: app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache ports: - "80:80" volumes: @@ -126,8 +126,8 @@ voir [la variante fpm](fpm.md). ## Versions de patch {#patch-releases} -Chaque version de patch de PHP a aussi son tag, par ex. `8.4.1-v5-cli`. Préférez le tag -`8.4-v5-cli` : il reçoit chaque version de patch (qui ne contient que des correctifs) et chaque +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 index 7161504..d32d396 100644 --- a/docs/fr/index.md +++ b/docs/fr/index.md @@ -1,10 +1,10 @@

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.4-v5-apache8.4-v5-fpm8.4-v5-cli8.4-v5-slim-apache8.4-v5-apache-node24 +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.4-v5-apache
+ thecodingmachine/php:8.6-v5-apache
## Choix et tuning {#choose-and-size} diff --git a/docs/fr/php-configuration.md b/docs/fr/php-configuration.md index d1189d3..78a4bc5 100644 --- a/docs/fr/php-configuration.md +++ b/docs/fr/php-configuration.md @@ -2,7 +2,7 @@ ## 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.4/php.ini-development) +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 @@ -16,7 +16,7 @@ Les variables d'environnement `PHP_INI_` définissent n'importe quel ```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/fr/processes.md b/docs/fr/processes.md index b2e283d..d641a37 100644 --- a/docs/fr/processes.md +++ b/docs/fr/processes.md @@ -26,7 +26,7 @@ Autre possibilité, un fichier exécutable monté sur `/etc/container/startup.sh ```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 ``` ## Tâches cron {#cron-jobs} @@ -71,7 +71,7 @@ le `FROM` : ```Dockerfile ARG INSTALL_CRON=1 -FROM thecodingmachine/php:8.4-v5-slim-apache +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 diff --git a/docs/fr/security.md b/docs/fr/security.md index 80f59c2..8bb9628 100644 --- a/docs/fr/security.md +++ b/docs/fr/security.md @@ -17,7 +17,7 @@ nouveaux paquets. Les tags des images : -- `X.Y-v5-*` (par ex. `8.4-v5-apache`) est mis à jour à chaque build : utilisez-le pour recevoir les correctifs. +- `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. diff --git a/docs/fr/variants.md b/docs/fr/variants.md index ad77b9f..cc4a2a9 100644 --- a/docs/fr/variants.md +++ b/docs/fr/variants.md @@ -16,7 +16,7 @@ Les images *cli* attendent une commande : remplacez la *command* Docker, jamais l'utilisateur, les tâches cron… voir [Processus](processes.md)). ```Dockerfile -FROM thecodingmachine/php:8.4-v5-cli +FROM thecodingmachine/php:8.6-v5-cli CMD ["php", "myprogram.php", "some_param"] ``` @@ -24,7 +24,7 @@ CMD ["php", "myprogram.php", "some_param"] ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-cli + image: thecodingmachine/php:8.6-v5-cli command: php myprogram.php some_param ``` @@ -66,7 +66,7 @@ Utilisez les variables d'environnement `APACHE_EXTENSION_` : ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache environment: APACHE_EXTENSION_DAV: 1 APACHE_EXTENSION_SSL: 1 @@ -99,7 +99,7 @@ et `php8.x` (`mod_php` n'est pas disponible). `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.4-v5-slim-apache a2enmod` +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} @@ -128,7 +128,7 @@ lui-même l'adresse de chaque intermédiaire : un header `X-Forwarded-For` ou `C ```yml services: app: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm environment: PHP_FPM_WEB_SERVER: apache # Le nom du service Traefik @@ -156,7 +156,7 @@ répertoire du serveur ou un volume sur `/var/log/apache2` : sans cela, les logs ```yml services: app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache environment: APACHE_LOG_FORMAT: json APACHE_LOG_OUTPUT: file @@ -172,7 +172,7 @@ Apache tourne sous l'utilisateur `docker`, qui a les droits du propriétaire de [Permissions](advanced.md#permissions)). En production, faites-le plutôt tourner sous `www-data` : ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache +FROM thecodingmachine/php:8.6-v5-apache ENV APACHE_RUN_USER=www-data \ APACHE_RUN_GROUP=www-data @@ -184,7 +184,7 @@ PHP-FPM écoute sur le port 9000 et parle FastCGI, pas HTTP : placez un serveur 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.4-v5-fpm +$ 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 @@ -199,7 +199,7 @@ conteneur, avec les fonctionnalités Apache de la variante *apache* (`.htaccess` (`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.4-v5-fpm +$ 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 @@ -227,7 +227,7 @@ comme healthcheck Docker ou comme sonde Kubernetes : ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm healthcheck: test: ["CMD", "php-fpm-healthcheck"] ``` diff --git a/docs/images.md b/docs/images.md index 6ba90eb..7e10d78 100644 --- a/docs/images.md +++ b/docs/images.md @@ -11,7 +11,7 @@ See the [variants](variants.md) to choose between *cli*, *apache* and *fpm*, and [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 @@ -26,7 +26,7 @@ extensions to install, `NODE_VERSION` installs NodeJS (with npm and yarn), in an ```Dockerfile ARG PHP_EXTENSIONS="apcu intl pdo_mysql" ARG NODE_VERSION=24 -FROM thecodingmachine/php:8.4-v5-slim-apache +FROM thecodingmachine/php:8.6-v5-slim-apache ENV TEMPLATE_PHP_INI=production @@ -42,7 +42,7 @@ The extensions are enabled with `PHP_EXTENSION_=1` (see [Extensions](exten the `-node` tags. ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache-node24 +FROM thecodingmachine/php:8.6-v5-apache-node24 ENV TEMPLATE_PHP_INI=production \ PHP_EXTENSION_INTL=1 @@ -58,7 +58,7 @@ from the fat image without NodeJS and install it from NodeSource; from NodeJS 25 `sudo npm install -g corepack` before `corepack enable`: ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache +FROM thecodingmachine/php:8.6-v5-apache RUN sudo apt-get update \ && sudo apt-get install -y --no-install-recommends gnupg \ @@ -78,7 +78,7 @@ In development, with the fat image and your project mounted: ```yml services: app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache ports: - "80:80" volumes: @@ -125,8 +125,8 @@ With a Dockerfile, replace `image:` with `build: .`. These examples use the *apa ## Patch releases -Each patch release of PHP also has its tag, e.g. `8.4.1-v5-cli`. Prefer the -`8.4-v5-cli` tag: it gets every patch release (which only contains bug fixes) and every rebuild of +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 95e1837..0ff747d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,10 +1,10 @@

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.4-v5-apache8.4-v5-fpm8.4-v5-cli8.4-v5-slim-apache8.4-v5-apache-node24 +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.4-v5-apache
+ thecodingmachine/php:8.6-v5-apache
## Choose and tune {#choose-and-size} 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 7e38858..aa5e78c 100644 --- a/docs/processes.md +++ b/docs/processes.md @@ -26,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 @@ -70,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 3236524..5e883b5 100644 --- a/docs/reverse-proxy/index.html +++ b/docs/reverse-proxy/index.html @@ -488,7 +488,7 @@

The fpm variant behind your own nginxs %O "%{Referer}i" "%{User-Agent}i"', detailed: '%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %D %{c}a', diff --git a/docs/security.md b/docs/security.md index 44946ae..81cf2dd 100644 --- a/docs/security.md +++ b/docs/security.md @@ -15,7 +15,7 @@ Outside of the security releases, each PHP version is also rebuilt within a day The tags of the images: -- `X.Y-v5-*` (e.g. `8.4-v5-apache`) is updated at each build: use it to get the fixes. +- `X.Y-v5-*` (e.g. `8.6-v5-apache`) is updated at each build: use it to get the fixes. - `X.Y.Z-v5-*` (e.g. `8.4.28-v5-apache`) is the last build of PHP X.Y.Z: it is published once amd64 and arm64 have the same PHP version, then updated by each build until the next PHP version. Use the digest of an image to pin it. - PHP 7.4, 8.0 and 8.1 are not maintained: they are rebuilt when sury publishes a fix for them, which keeps the PHP diff --git a/docs/tuning/index.html b/docs/tuning/index.html index 7cd4298..65e96e9 100644 --- a/docs/tuning/index.html +++ b/docs/tuning/index.html @@ -824,7 +824,7 @@

4Configuration4Configuration4Configuration` environment variables: ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache environment: APACHE_EXTENSION_DAV: 1 APACHE_EXTENSION_SSL: 1 @@ -97,7 +97,7 @@ For the built-in Apache of the *fpm* variant, `mpm_event` `proxy` `proxy_fcgi` a `socache_dbm` `socache_memcache` `socache_redis` `socache_shmcb` `speling` `ssl` `status` `substitute` `suexec` `unique_id` `userdir` `usertrack` `vhost_alias` `xml2enc` -This list can be outdated, you can verify it with: `docker run --rm thecodingmachine/php:8.4-v5-slim-apache a2enmod` +This list can be outdated, you can verify it with: `docker run --rm thecodingmachine/php:8.6-v5-slim-apache a2enmod` ### Connections and processes @@ -126,7 +126,7 @@ ignored. ```yml services: app: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm environment: PHP_FPM_WEB_SERVER: apache # The name of the Traefik service @@ -154,7 +154,7 @@ it, the logs are lost with the container. ```yml services: app: - image: thecodingmachine/php:8.4-v5-apache + image: thecodingmachine/php:8.6-v5-apache environment: APACHE_LOG_FORMAT: json APACHE_LOG_OUTPUT: file @@ -170,7 +170,7 @@ Apache runs as the `docker` user, which has the rights of the owner of your file [Permissions](advanced.md#permissions)). In production, run it as `www-data` instead: ```Dockerfile -FROM thecodingmachine/php:8.4-v5-apache +FROM thecodingmachine/php:8.6-v5-apache ENV APACHE_RUN_USER=www-data \ APACHE_RUN_GROUP=www-data @@ -182,7 +182,7 @@ PHP-FPM listens on port 9000 and speaks FastCGI, not HTTP: put a web server (ngi in another container, and point it to `fpm-container:9000`. ```bash -$ docker run -p 9000:9000 --rm -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-fpm +$ docker run -p 9000:9000 --rm -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm ``` A `docker stop` stops PHP-FPM gracefully (`SIGQUIT`), with or without the built-in Apache: the running requests are @@ -197,7 +197,7 @@ container, with the Apache features of the *apache* variant (`.htaccess`, [docum by default). ```bash -$ docker run -p 80:80 --rm -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.4-v5-fpm +$ docker run -p 80:80 --rm -e PHP_FPM_WEB_SERVER=apache -v "$PWD":/var/www/html thecodingmachine/php:8.6-v5-fpm ``` [Serving an application with the fpm variant](fpm.md) details its advantages, the constraints of PHP-FPM (number of @@ -225,7 +225,7 @@ healthcheck or as a Kubernetes probe: ```yml services: my_app: - image: thecodingmachine/php:8.4-v5-fpm + image: thecodingmachine/php:8.6-v5-fpm healthcheck: test: ["CMD", "php-fpm-healthcheck"] ``` diff --git a/orbit-images.yml b/orbit-images.yml index 3b52f23..c37a512 100644 --- a/orbit-images.yml +++ b/orbit-images.yml @@ -1,2 +1,2 @@ -php_version: "8.4" +php_version: "8.6" node_version: "24" From df97de86ebe1d3fc272c3a9009adde82bbf72316 Mon Sep 17 00:00:00 2001 From: Mistral OZ - MIO Date: Sat, 5 Dec 2026 10:54:54 +0100 Subject: [PATCH 6/6] French extensions page: swoole and spx not available in PHP 8.6 --- docs/fr/extensions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/fr/extensions.md b/docs/fr/extensions.md index 0a42c21..a23d433 100644 --- a/docs/fr/extensions.md +++ b/docs/fr/extensions.md @@ -32,6 +32,8 @@ Cette liste peut être obsolète, vous pouvez la vérifier avec : `docker run -- **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