Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions ci/image-tests/Checks/PhpChecks.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use function array_combine;
use function array_map;
use function escapeshellarg;
use function implode;
use function json_decode;
use function preg_quote;
use function sprintf;
Expand Down Expand Up @@ -151,6 +152,21 @@ public function testAptUsesContribAndNonFree(): void
}
}

/**
* docker-php-setting, in a container of its own: it appends the setting to /opt/docker/etc/php/php.ini, which PHP
* and PHP-FPM read after the settings from the environment; a value that is not a number is quoted unless --raw.
*/
public function testDockerPhpSettingChangesASetting(): void
{
$result = $this->runContainer(['sh', '-c', implode(' && ', [
'docker-php-setting memory_limit 384M > /dev/null',
'docker-php-setting --raw error_reporting E_ERROR > /dev/null',
"php -r 'echo ini_get(\"memory_limit\"), \" \", ini_get(\"error_reporting\"), PHP_EOL;'",
'php-fpm -i | grep "^memory_limit "',
])], ['PHP_MEMORY_LIMIT' => '256M']);
self::assertSame([0, "384M 1\nmemory_limit => 384M => 384M\n"], [$result->exitCode, $result->stdout], $result->describe());
}

public function testPhpComputesSha1(): void
{
$result = $this->assertCommandSucceeds("php -r 'echo sha1(\"webdevops\");'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
14 changes: 5 additions & 9 deletions docker/php-official/8.2/conf/bin/usr-bin/docker-php-setting
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
14 changes: 5 additions & 9 deletions docker/php-official/8.3/conf/bin/usr-bin/docker-php-setting
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
14 changes: 5 additions & 9 deletions docker/php-official/8.4/conf/bin/usr-bin/docker-php-setting
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
14 changes: 5 additions & 9 deletions docker/php-official/8.5/conf/bin/usr-bin/docker-php-setting
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
3 changes: 2 additions & 1 deletion docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ These commands are installed in the images. Use them in `RUN` lines of your own
| --- | --- | --- |
| `apt-install <packages>` | Runs `apt-get update`, installs the packages without recommended packages and removes the package lists again | Debian- and Ubuntu-based images, including `bootstrap:ubuntu-22.04` |
| `apk-install <packages>` | Installs packages with `apk add --no-cache` | Alpine-based images, including `bootstrap:alpine` |
| `docker-php-setting [--raw] <setting> <value>` | Appends a PHP setting to `/opt/docker/etc/php/php.ini`, for example `docker-php-setting memory_limit 384M`. PHP and PHP-FPM read that file after the [PHP variables](environment-variables.md#php), so the setting wins over them. A value that is not a number is written in quotes; `--raw` writes it as it is, for example `docker-php-setting --raw error_reporting E_ERROR` | `php-*` |
| `docker-image-cleanup` | Removes package lists and caches; use it at the end of a `RUN` that installed packages | all except `toolbox`; fails in the Alpine `php-*` images, see [Known issues](known-issues.md#docker-image-cleanup-in-the-alpine-php-images) |
| `file <path>` | Shows the type of a file, for example `file --mime-type upload.bin`; tools such as GrumPHP's BOM check call it | `php`, `php-apache`, `php-nginx` and their `-dev` images |
| `go-replace -s <search> -r <replace> -- <file>` | Replaces text in files; the same tool fills the [placeholders](#placeholders) | all |
Expand Down Expand Up @@ -295,7 +296,7 @@ Images: `php-*`. Files in `/opt/docker/etc/php/`:
| File | Content |
| --- | --- |
| `php.webdevops.ini` | The image's PHP defaults, followed by the values of the `php.*` and `PHP_*` variables. Loaded as `98-webdevops.ini`. At every start it is reset to the image's version and the variables are written again, so do not replace or edit it. |
| `php.ini` | For your settings, empty by default. Loaded as `99-docker.ini`, after `98-webdevops.ini`, so its values win over the environment variables. A `:ro` mount works. |
| `php.ini` | For your settings, empty by default; [`docker-php-setting`](#tools-for-your-dockerfile) appends to it. Loaded as `99-docker.ini`, after `98-webdevops.ini`, so its values win over the environment variables. A `:ro` mount works. |
| `fpm/php-fpm.conf` | PHP-FPM main configuration; `FPM_PROCESS_MAX` and `fpm.global.*` are appended at every start. |
| `fpm/pool.d/application.conf` | The PHP-FPM pool `[www]`; the `FPM_*` and `fpm.pool.*` values are appended at every start. To replace it, use `COPY` in a Dockerfile: with a `:ro` mount the container exits at start, and a read-write mount gets the values appended in the file on the host. |

Expand Down
6 changes: 0 additions & 6 deletions docs/known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ These options and tools are part of the images but do not work, or work only in

## Problems in the images

### `docker-php-setting`

- **Effect:** Always prints its usage text and exits with code 1, also for a valid call such as `docker-php-setting memory_limit 512M`. The setting is not changed.
- **Images:** `php-*`, Debian and Alpine.
- **Instead:** Set `php.<key>` or a shortcut such as `PHP_MEMORY_LIMIT`, see [PHP](environment-variables.md#php), or [replace `php.ini`](customization.md#php).

### `SERVICE_POSTFIX_OPTS`

- **Effect:** No effect. The value is passed to `postfix start`, which ignores it.
Expand Down
14 changes: 5 additions & 9 deletions provisioning/php/general/bin/usr-bin/docker-php-setting
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ PHP_VALUE_RAW=0
PHP_KEY=
PHP_VALUE=

for arg in "$@"; do
case "$arg" in
--raw)
PHP_VALUE_RAW=1
shift
;;
esac
done
if [[ "${1:-}" == "--raw" ]]; then
PHP_VALUE_RAW=1
shift
fi

if [[ "$#" -le 2 ]]; then
if [[ "$#" -lt 2 ]]; then
echo "Usage: $(basename "$0") [--raw] <setting> <value>"
exit 1
fi
Expand Down
Loading