Skip to content

Fix image size (apt caches), fpm graceful stop, stop during startup and Apache modules - #415

Merged
mistraloz merged 3 commits into
thecodingmachine:v5from
mistraloz:fix/slim-size-and-fpm-stop
Oct 9, 2026
Merged

mistraloz merged 3 commits into
thecodingmachine:v5from
mistraloz:fix/slim-size-and-fpm-stop

Conversation

@mistraloz

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes :

  • Bug
  • Feature
  • Breaking changes
  1. Image size: images built FROM a slim image got a ~110MB layer from the ONBUILD hook, even without any
    extension (PHP_EXTENSIONS empty), and fat images carried the same garbage. The install scripts disable the
    docker-clean apt configuration while installing: apt-get update then creates /var/cache/apt/pkgcache.bin and
    srcpkgcache.bin (~105MB) that apt-get clean no longer knows once docker-clean is restored.
    The hook now exits right away when PHP_EXTENSIONS is empty, and the caches are removed explicitly.
  2. fpm graceful stop: STOPSIGNAL SIGQUIT (PHP-FPM completes the running requests) and EXPOSE 9000.
  3. Stop requested while the container is starting: the stop signal was lost and the container was killed after
    the stop timeout (exit 137 after 10s). bash always ignores SIGQUIT (fpm) and ignores SIGWINCH (apache) by
    default. The entrypoint and apache2-foreground now trap them. SIGTERM/SIGINT (cli) are not trapped: they
    already stop bash right away (and trapping them would delay the stop until the end of a long startup command).
  4. Apache modules: brotli, cern_meta, imagemap, md, proxy_hcheck, proxy_uwsgi and socache_redis are
    shipped by Ubuntu and documented as available, but were ignored (APACHE_EXTENSION_*) or rejected
    (APACHE_EXTENSIONS).
  5. Minor: the sed commenting the default listen socket of www.conf did nothing (single quotes). No visible effect,
    zz-docker.conf already overrides listen.

/var/cache/apt (PHP 8.4, amd64):

Image Before After
FROM thecodingmachine/php:8.4-v5-slim-cli (ONBUILD, PHP_EXTENSIONS empty) 105 MB 12 kB
8.4-v5-cli (fat) 105 MB 12 kB

Related issues: #358 (slow shutdown, not reproducible on v5 anymore: 0.1-0.6 s, graceful now), #215 (Apache
SIGWINCH: after the initialization it already works on v5, the remaining case was a stop during the
initialization, fixed here).

Test plan (required)

New tests: test_gracefulStop and test_stopDuringStartup (fpm), test_stopDuringStartup and
test_enableApacheModule (apache).

TAG_PREFIX=pr1- docker buildx bake --load php84-slim-<variant> php84-<variant>
TAG_PREFIX=pr1- PHP_VERSION=8.4 BRANCH=v5 VARIANT=<variant> ./tests-suite/bash_unit -f tap ./tests-suite/*.sh
PHP cli apache fpm
8.2 28/28 35/35 31/31
8.3 28/28 35/35 31/31
8.4 28/28 35/35 31/31
8.5 28/28 35/35 31/31

(amd64 locally, arm64 by the CI)

Checklist

  • I followed the guidelines in CONTRIBUTING guide
  • I have squashed any insignificant commits
  • This change has comments for package types, values, functions, and non-obvious lines of code

@mistraloz mistraloz added the bug Something isn't working label Oct 9, 2026
…ages

The extension install scripts disable the docker-clean apt configuration while
installing: apt-get update then creates /var/cache/apt/pkgcache.bin and
srcpkgcache.bin (~105MB) that apt-get clean no longer knows once docker-clean is
restored, so they stayed in the image layer.

- The ONBUILD hook no longer runs apt when PHP_EXTENSIONS is empty
- The apt binary caches are removed explicitly (ONBUILD hook and fat images)
…artup

- fpm variant: STOPSIGNAL SIGQUIT (PHP-FPM graceful stop, running requests are
  completed) and EXPOSE 9000
- Stop signals ignored by bash were lost while the container was initializing,
  and the container was killed after the stop timeout: SIGQUIT (fpm) is always
  ignored by bash, SIGWINCH (apache) by default. The entrypoint and
  apache2-foreground now trap them. SIGTERM and SIGINT (cli) are not trapped:
  they already stop bash right away.
- Fix the sed commenting the default listen socket in www.conf (single quotes
  prevented the PHP_VERSION expansion)
brotli, cern_meta, imagemap, md, proxy_hcheck, proxy_uwsgi and socache_redis
were listed as available in the README but silently ignored
(APACHE_EXTENSION_*) or rejected (APACHE_EXTENSIONS).
@mistraloz
mistraloz force-pushed the fix/slim-size-and-fpm-stop branch from 4e5fbf2 to 1d18372 Compare October 9, 2026 11:52
@mistraloz
mistraloz merged commit d1ca17d into thecodingmachine:v5 Oct 9, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant