From ff28c49d94da8afb9de02caee09b536d92258f32 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 26 Nov 2026 20:53:49 +0000 Subject: [PATCH] Add common PHP extensions and keep PHP sessions in /tmp PHP could not start a session in a box. The session files went to /var/lib/php/sessions, which is on the read-only root filesystem. The sessions now go to the /tmp tmpfs. Ubuntu removes old sessions with a cron job, and a box runs no cron, so PHP now removes them itself. The full image also lacked common PHP extensions. It now installs bz2, gmp, mysql, pgsql, ldap and soap. The image test checks the session path and these extensions. --- box-image/Dockerfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/box-image/Dockerfile b/box-image/Dockerfile index 550d604..5f0d946 100644 --- a/box-image/Dockerfile +++ b/box-image/Dockerfile @@ -430,11 +430,23 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ php-sqlite3 \ php-gd \ php-bcmath \ + php-bz2 \ + php-gmp \ + php-mysql \ + php-pgsql \ + php-ldap \ + php-soap \ composer \ pkg-config \ libssl-dev \ && rm -rf /var/lib/apt/lists/* +# PHP keeps its sessions in /tmp, because the root filesystem is read-only at +# runtime. Ubuntu removes old sessions with a cron job, and a box runs no +# cron. So PHP removes them itself. +RUN printf 'session.save_path = /tmp\nsession.gc_probability = 1\n' \ + > "$(php -r 'echo PHP_CONFIG_FILE_SCAN_DIR;')/99-boxes.ini" + # Tools for documents, archives and databases. /usr is read-only at runtime, # so the agent cannot add them later. # @@ -684,6 +696,10 @@ RUN set -eu; \ cd /tmp/hello-rs && cargo build --quiet --offline && ./target/debug/hello-rs >/dev/null; \ command -v rustfmt >/dev/null && command -v cargo-clippy >/dev/null; \ test "$(php -r 'echo "ok";')" = "ok"; \ + test "$(php -r 'echo session_save_path();')" = "/tmp"; \ + for m in bz2 gmp mysqli pdo_mysql pgsql pdo_pgsql ldap soap; do \ + php -m | grep -qx "$m" || { echo "missing PHP extension: $m" >&2; exit 1; }; \ + done; \ composer --version >/dev/null RUN touch /tmp/checks-passed