diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..decaff9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# EditorConfig is awesome: http://EditorConfig.org + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[Makefile] +indent_style = tab + +[*.{json,yml,yaml}] +indent_size = 2 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..eeec454 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,28 @@ +# Dockette / PHP + +PHP CLI and FPM images with Composer and common extensions, one tag per PHP version. + +## Stack + +- Docker image built with `docker buildx`, base `dockette/debian:bookworm` +- PHP 5.6 to 8.5 from packages.sury.org, each as CLI and `-fpm`, with Composer +- Published to Docker Hub as `dockette/php` by GitHub Actions + +## Development + +```bash +make build # build the image (VERSION=8.5) +make test # smoke test the CLI and FPM images (VERSION=8.5) +make run # run it locally with the current folder in /srv +make build-8.4 # build one version; also build-8.4-fpm +``` + +`make build VERSION=8.4` builds one version. Run `make` to list every target. + +## Principles + +- KISS: one image does one job; no extra services or tools. +- DRY: shared steps live in the base image, not copied into every Dockerfile. +- YAGNI: add a package only when the image needs it. +- Pin versions, keep layers small, clean package caches in the same `RUN`. +- Every change is built and smoke tested with `make build test` before a commit. diff --git a/Makefile b/Makefile index f6c8e07..bca73de 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,24 @@ DOCKER_IMAGE=dockette/php DOCKER_PLATFORM?=linux/amd64 VERSION?=8.5 -.PHONY: build test run test-cli-% test-fpm-% test-pcov-% +.DEFAULT_GOAL := help -build: build-${VERSION} +##@ Help -test: test-cli-${VERSION} test-fpm-${VERSION} +.PHONY: help +help: ## Show this help + @awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m\033[0m\n"} /^[a-zA-Z0-9_.-]+:.*##/ { sub(/^ +/, "", $$2); printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(firstword $(MAKEFILE_LIST)) -run: +##@ Docker + +.PHONY: build +build: build-${VERSION} ## Build one image (VERSION=8.5 or VERSION=8.5-fpm) + +.PHONY: test +test: test-cli-${VERSION} test-fpm-${VERSION} ## Test the CLI and FPM images of VERSION (VERSION=8.5, no -fpm) + +.PHONY: run +run: ## Run the image with the current folder in /srv (VERSION=8.5) docker run --rm -it -v ${PWD}:/srv ${DOCKER_IMAGE}:${VERSION} _build-%: VERSION=$* @@ -20,31 +31,6 @@ _build-%: -t ${DOCKER_IMAGE}:${VERSION} \ ./${VERSION} -build-5.6: _build-5.6 -build-5.6-fpm: _build-5.6-fpm -build-7.0: _build-7.0 -build-7.0-fpm: _build-7.0-fpm -build-7.1: _build-7.1 -build-7.1-fpm: _build-7.1-fpm -build-7.2: _build-7.2 -build-7.2-fpm: _build-7.2-fpm -build-7.3: _build-7.3 -build-7.3-fpm: _build-7.3-fpm -build-7.4: _build-7.4 -build-7.4-fpm: _build-7.4-fpm -build-8.0: _build-8.0 -build-8.0-fpm: _build-8.0-fpm -build-8.1: _build-8.1 -build-8.1-fpm: _build-8.1-fpm -build-8.2: _build-8.2 -build-8.2-fpm: _build-8.2-fpm -build-8.3: _build-8.3 -build-8.3-fpm: _build-8.3-fpm -build-8.4: _build-8.4 -build-8.4-fpm: _build-8.4-fpm -build-8.5: _build-8.5 -build-8.5-fpm: _build-8.5-fpm - test-cli-%: docker run --rm ${DOCKER_IMAGE}:$* sh -lc 'php -v && composer --version' ${MAKE} test-pcov-$* @@ -57,3 +43,77 @@ test-fpm-%: test-pcov-%: docker run --rm ${DOCKER_IMAGE}:$* php -r 'exit(PHP_VERSION_ID < 70100 || extension_loaded("pcov") ? 0 : 1);' \ || { echo "ERROR: pcov is not loaded in ${DOCKER_IMAGE}:$*" >&2; exit 1; } + +##@ Versions + +.PHONY: build-5.6 +build-5.6: _build-5.6 ## Build the PHP 5.6 CLI image + +.PHONY: build-5.6-fpm +build-5.6-fpm: _build-5.6-fpm ## Build the PHP 5.6 FPM image + +.PHONY: build-7.0 +build-7.0: _build-7.0 ## Build the PHP 7.0 CLI image + +.PHONY: build-7.0-fpm +build-7.0-fpm: _build-7.0-fpm ## Build the PHP 7.0 FPM image + +.PHONY: build-7.1 +build-7.1: _build-7.1 ## Build the PHP 7.1 CLI image + +.PHONY: build-7.1-fpm +build-7.1-fpm: _build-7.1-fpm ## Build the PHP 7.1 FPM image + +.PHONY: build-7.2 +build-7.2: _build-7.2 ## Build the PHP 7.2 CLI image + +.PHONY: build-7.2-fpm +build-7.2-fpm: _build-7.2-fpm ## Build the PHP 7.2 FPM image + +.PHONY: build-7.3 +build-7.3: _build-7.3 ## Build the PHP 7.3 CLI image + +.PHONY: build-7.3-fpm +build-7.3-fpm: _build-7.3-fpm ## Build the PHP 7.3 FPM image + +.PHONY: build-7.4 +build-7.4: _build-7.4 ## Build the PHP 7.4 CLI image + +.PHONY: build-7.4-fpm +build-7.4-fpm: _build-7.4-fpm ## Build the PHP 7.4 FPM image + +.PHONY: build-8.0 +build-8.0: _build-8.0 ## Build the PHP 8.0 CLI image + +.PHONY: build-8.0-fpm +build-8.0-fpm: _build-8.0-fpm ## Build the PHP 8.0 FPM image + +.PHONY: build-8.1 +build-8.1: _build-8.1 ## Build the PHP 8.1 CLI image + +.PHONY: build-8.1-fpm +build-8.1-fpm: _build-8.1-fpm ## Build the PHP 8.1 FPM image + +.PHONY: build-8.2 +build-8.2: _build-8.2 ## Build the PHP 8.2 CLI image + +.PHONY: build-8.2-fpm +build-8.2-fpm: _build-8.2-fpm ## Build the PHP 8.2 FPM image + +.PHONY: build-8.3 +build-8.3: _build-8.3 ## Build the PHP 8.3 CLI image + +.PHONY: build-8.3-fpm +build-8.3-fpm: _build-8.3-fpm ## Build the PHP 8.3 FPM image + +.PHONY: build-8.4 +build-8.4: _build-8.4 ## Build the PHP 8.4 CLI image + +.PHONY: build-8.4-fpm +build-8.4-fpm: _build-8.4-fpm ## Build the PHP 8.4 FPM image + +.PHONY: build-8.5 +build-8.5: _build-8.5 ## Build the PHP 8.5 CLI image + +.PHONY: build-8.5-fpm +build-8.5-fpm: _build-8.5-fpm ## Build the PHP 8.5 FPM image diff --git a/README.md b/README.md index 78a20b0..9bf92c2 100644 --- a/README.md +++ b/README.md @@ -1,117 +1,106 @@

Dockette / PHP

- Ready-to-use Debian based images for PHP 5.6-8.5 with CLI or FPM and Composer preinstalled. + GitHub Actions + Docker Hub pulls + GitHub Sponsors + Support/Discussions

- Trying to follow the latest releases with official PHP. + PHP 5.6 to 8.5 CLI and FPM images on Debian Bookworm, with Composer 2 and about 25 extensions installed. PHP comes from the Sury packages. For running PHP tools and applications in CI and local development, and as a base for your own images.

🕹 f3l1x.io | 💻 f3l1x | 🐦 @xf3l1x

-

- GitHub Actions - Docker Hub pulls - GitHub Sponsors - Support/Discussions -

- ----- ## Usage -``` -docker run -v /path/to/site:/srv dockette/php:8.5 -docker run -v /path/to/site:/srv dockette/php:8.5-fpm -docker run -v /path/to/site:/srv dockette/php:8.4 -docker run -v /path/to/site:/srv dockette/php:8.4-fpm -docker run -v /path/to/site:/srv dockette/php:8.3 -docker run -v /path/to/site:/srv dockette/php:8.3-fpm -docker run -v /path/to/site:/srv dockette/php:8.2 -docker run -v /path/to/site:/srv dockette/php:8.2-fpm -docker run -v /path/to/site:/srv dockette/php:8.1 -docker run -v /path/to/site:/srv dockette/php:8.1-fpm -docker run -v /path/to/site:/srv dockette/php:8.0 -docker run -v /path/to/site:/srv dockette/php:8.0-fpm -docker run -v /path/to/site:/srv dockette/php:7.4 -docker run -v /path/to/site:/srv dockette/php:7.4-fpm -docker run -v /path/to/site:/srv dockette/php:7.3 -docker run -v /path/to/site:/srv dockette/php:7.3-fpm -docker run -v /path/to/site:/srv dockette/php:7.2 -docker run -v /path/to/site:/srv dockette/php:7.2-fpm -docker run -v /path/to/site:/srv dockette/php:7.1 -docker run -v /path/to/site:/srv dockette/php:7.1-fpm -docker run -v /path/to/site:/srv dockette/php:7.0 -docker run -v /path/to/site:/srv dockette/php:7.0-fpm -docker run -v /path/to/site:/srv dockette/php:5.6 -docker run -v /path/to/site:/srv dockette/php:5.6-fpm +Mount your project in `/srv` and run a command in it: + +```sh +docker run -v "$(pwd)":/srv dockette/php:8.5 composer install ``` -**Base image** +The image adds Composer 2, about 25 extensions and a `custom.ini` with PHP limits and the `Europe/Prague` time +zone. The `-fpm` tags run PHP-FPM with one FastCGI pool on port `9000` and `open_basedir` set to +`/data:/srv:/var/tmp:/tmp`; mount your own `.ini` file into `/etc/php/8.5/cli/conf.d` or +`/etc/php/8.5/fpm/conf.d` to change a setting, see the [PHP configuration reference](https://www.php.net/manual/en/ini.list.php). -```Dockerfile -FROM dockette/php:8.5-fpm +## Versions -RUN apt update && apt install -y curl -``` +Every version has a CLI tag and an `-fpm` tag. Each is built for `linux/amd64` and `linux/arm64` and rebuilt +every Monday. There is no `latest` tag; pin a version. -## Documentation +| Tag | Base | Upstream EOL | State | +|-----|------|--------------|-------| +| `dockette/php:8.5`, `dockette/php:8.5-fpm` | `dockette/debian:bookworm` | 2029-12-31 | Supported | +| `dockette/php:8.4`, `dockette/php:8.4-fpm` | `dockette/debian:bookworm` | 2028-12-31 | Supported | +| `dockette/php:8.3`, `dockette/php:8.3-fpm` | `dockette/debian:bookworm` | 2027-12-31 | Supported | +| `dockette/php:8.2`, `dockette/php:8.2-fpm` | `dockette/debian:bookworm` | 2026-12-31 | Supported | +| `dockette/php:8.1`, `dockette/php:8.1-fpm` | `dockette/debian:bookworm` | 2025-12-31 | Legacy (EOL runtime) | +| `dockette/php:8.0`, `dockette/php:8.0-fpm` | `dockette/debian:bookworm` | 2023-11-26 | Legacy (EOL runtime) | +| `dockette/php:7.4`, `dockette/php:7.4-fpm` | `dockette/debian:bookworm` | 2022-11-28 | Legacy (EOL runtime) | +| `dockette/php:7.3`, `dockette/php:7.3-fpm` | `dockette/debian:bookworm` | 2021-12-06 | Legacy (EOL runtime) | +| `dockette/php:7.2`, `dockette/php:7.2-fpm` | `dockette/debian:bookworm` | 2020-11-30 | Legacy (EOL runtime) | +| `dockette/php:7.1`, `dockette/php:7.1-fpm` | `dockette/debian:bookworm` | 2019-12-01 | Legacy (EOL runtime) | +| `dockette/php:7.0`, `dockette/php:7.0-fpm` | `dockette/debian:bookworm` | 2019-01-10 | Legacy (EOL runtime) | +| `dockette/php:5.6`, `dockette/php:5.6-fpm` | `dockette/debian:bookworm` | 2018-12-31 | Legacy (EOL runtime) | -### Linux packages +> [!WARNING] +> PHP 8.1 and older get no security fixes from upstream. The Legacy tags keep building while Debian Bookworm is +> supported; use them only to run old code. -These images have preinstalled couple of linux packages: apt-transport-https ca-certificates git. +## Packages -### PHP extensions +The images include `apt-transport-https`, `ca-certificates`, `git`, `unzip` and Composer 2 in +`/usr/local/bin/composer`. Every version has the `cli`, `cgi` and `phpdbg` SAPIs; the `-fpm` tags add `fpm`. -These images have preinstalled a couple of PHP extensions. The table shows which extension each version has. +The extensions per version: | Extension | 5.6 | 7.0 | 7.1 | 7.2 | 7.3 | 7.4 | 8.0 | 8.1 | 8.2 | 8.3 | 8.4 | 8.5 | |---|---|---|---|---|---|---|---|---|---|---|---|---| -| apcu | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| bcmath | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| bz2 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| calendar | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| ctype | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| curl | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| gd | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| geoip | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | -| gettext | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| imagick | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | -| imap | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| intl | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| ldap | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| mbstring | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| mcrypt | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | -| memcached | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| mysql | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| pcov | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| pdo | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| pgsql | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| redis | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | -| soap | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| sqlite3 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| ssh2 | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | -| xmlrpc | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| xsl | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| zip | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | - -All versions also have these SAPIs: cli, cgi and phpdbg. The `*-fpm` images have fpm in addition. - -### Composer - -![Composer](https://avatars3.githubusercontent.com/u/837015?v=3&s=200) - -This super image has also preinstalled [Composer](https://getcomposer.org). - -### Customization - -In case of customization PHP 5.6 - 8.5: - -- /etc/php/{5.6-8.5}/{cli,cgi,fpm}/conf.d/991-custom.ini +| apcu | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| bcmath | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| bz2 | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| calendar | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| ctype | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| curl | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| gd | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| geoip | yes | yes | yes | yes | yes | yes | - | - | - | - | - | - | +| gettext | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| imagick | yes | yes | yes | - | - | - | - | - | - | - | - | - | +| imap | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| intl | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| ldap | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| mbstring | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| mcrypt | yes | yes | yes | - | - | - | - | - | - | - | - | - | +| memcached | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| mysql | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| pcov | - | - | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| pdo | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| pgsql | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| redis | yes | yes | yes | yes | yes | yes | yes | yes | - | - | - | - | +| soap | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| sqlite3 | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| ssh2 | yes | yes | yes | yes | - | - | - | - | - | - | - | - | +| xmlrpc | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| xsl | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | +| zip | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | yes | + +## Development + +```sh +make build # build the image (VERSION=8.5) +make test # smoke test the CLI and FPM image +make run # run it with the current folder in /srv +``` + +Run `make` to list every target. ## Maintenance -See [how to contribute](https://github.com/dockette/.github/blob/master/CONTRIBUTING.md) to this package. Consider to [support](https://github.com/sponsors/f3l1x) **f3l1x**. Thank you for using this package. +See [how to contribute](https://github.com/dockette/.github/blob/master/CONTRIBUTING.md) to this package. Consider [supporting](https://github.com/sponsors/f3l1x) **f3l1x**. Thank you for using this package. diff --git a/fxnorm.yml b/fxnorm.yml new file mode 100644 index 0000000..5b45951 --- /dev/null +++ b/fxnorm.yml @@ -0,0 +1,12 @@ +# fxnorm configuration, written by `fxnorm init`. +# `fxnorm config` prints what runs and why; `fxnorm rules` lists every rule with its group. + +# A Dockette Docker image repository (a Dockerfile in the root or one folder below) +presets: + - dockette-image + +# groups: # add a group, or drop one with a leading minus +# - -ci + +# rules: # false, true, error, warning, or options +# common/agents-md-length: {min: 50, max: 120}