|
|
@@ -11,6 +11,7 @@
|
|
|
set -euo pipefail
|
|
|
|
|
|
APP_ROOT="${APP_ROOT:-/var/www/html}"
|
|
|
+DATA_PATH="${DATA_PATH:-/var/www/data}"
|
|
|
# R01-N27: session-storage path (defaults match Dockerfile + .env.example).
|
|
|
SESSION_PATH="${SESSION_PATH:-/var/www/data/sessions}"
|
|
|
# R01-N27: session-file lifetime in minutes. Default 480 (= 8h), matching
|
|
|
@@ -20,9 +21,21 @@ SESSION_GC_MAX_AGE_MINUTES="${SESSION_GC_MAX_AGE_MINUTES:-480}"
|
|
|
# R01-N27: how often to sweep, in seconds. Default 3600 (= once per hour).
|
|
|
SESSION_GC_INTERVAL_SECONDS="${SESSION_GC_INTERVAL_SECONDS:-3600}"
|
|
|
|
|
|
+# Self-heal data-dir ownership: when a host bind mount is attached at
|
|
|
+# /var/www/data (dev compose) the host's uid/gid masks the Dockerfile's
|
|
|
+# `chown www-data` and SQLite + session writes fail with a confusing
|
|
|
+# "readonly database". Fix it on every start while we're still root —
|
|
|
+# once before migrate so it can open the DB, and once after, because
|
|
|
+# migrate runs as root and would otherwise leave new SQLite files
|
|
|
+# (and the WAL/SHM siblings) owned by root.
|
|
|
+mkdir -p "${DATA_PATH}" "${SESSION_PATH}"
|
|
|
+chown -R www-data:www-data "${DATA_PATH}"
|
|
|
+
|
|
|
echo "[entrypoint] running deploy-time migrations…"
|
|
|
php "${APP_ROOT}/bin/migrate.php"
|
|
|
|
|
|
+chown -R www-data:www-data "${DATA_PATH}"
|
|
|
+
|
|
|
# R01-N27: PHP's built-in session GC fires probabilistically off request
|
|
|
# traffic, so a low-traffic deployment keeps stale session files for days
|
|
|
# past `gc_maxlifetime`. This backgrounded loop deletes session files
|