Skip to content

fix(setup): detect Symfony on fresh deploys — var/cache cannot be the marker it creates - #137

Merged
sylvesterdamgaard merged 1 commit into
mainfrom
fix/framework-detection
Sep 7, 2026
Merged

sylvesterdamgaard merged 1 commit into
mainfrom
fix/framework-detection

Conversation

@sylvesterdamgaard

Copy link
Copy Markdown
Contributor

Problem

detectFramework() classified an app as Symfony only when bin/console and an existing var/cache directory were present. But var/cache is exactly what setupSymfony() creates — chicken-and-egg: a fresh Symfony deploy (or bind mount without var/) is detected as generic, its cache directory is never created, and the app fails health checks with an unwritable var/cache.

Found via the php-baseimages E2E suite: the Symfony scenario's app reported cache: writable=false forever because init logged Setting up permissions framework=generic.

Fix

  • Symfony: corroborate bin/console with symfony.lock (Flex-managed apps) or a symfony/framework-bundle composer dependency — markers every real Symfony app has before first boot.
  • Laravel: same corroboration pattern (artisan + composer dependency or bootstrap/app.php, which artisan itself requires) so a stray file named artisan no longer triggers Laravel permission handling.
  • Mirrors the shell-side detection in php-baseimages' entrypoint-lib.sh.

Tests

  • TestDetectFramework extended: fresh-deploy Symfony without var/, symfony.lock variant, composer-dependency variants for both frameworks, and negative cases (stray artisan, bare bin/console).
  • TestPermissionManager_Setup Symfony fixture now deliberately omits var/ to prove Setup() creates it.
  • gofmt clean, go vet clean, golangci-lint v2.12.2: 0 issues, full go test ./... green.

… marker it creates

Framework detection required var/cache to exist before classifying an app
as Symfony, but var/cache is exactly what setupSymfony() creates. A fresh
deploy was therefore detected as generic, its cache directory never made,
and the app failed health checks with an unwritable var/cache.

Detection now corroborates bin/console with symfony.lock or a
symfony/framework-bundle composer dependency. Laravel detection gets the
same treatment (artisan plus composer dependency or bootstrap/app.php) so
a stray artisan file no longer triggers Laravel permission handling.
sylvesterdamgaard added a commit to cboxdk/php-baseimages that referenced this pull request Sep 7, 2026
…e skips, fixture repairs

The full local run exposed suite bugs masking each other as image failures:

- Runner: scenarios only cleaned up on success, so one failure leaked its
  compose stack and the shared ports (8090-8096) sank every later scenario.
  The runner now tears down the scenario's compose project AND any leftover
  e2e-* containers after every scenario, pass or fail.
- Runner: chromium-only scenarios (browsershot, dusk-capabilities) are
  skipped with a message on images without Chromium instead of failing;
  the rootless scenario runs against ROOTLESS_IMAGE when provided and
  skips when the image under test is not rootless.
- Scenarios: 32 VAR=$(docker exec ...) substitutions could kill a scenario
  mid-run under set -e before its own verdict; all now carry || true.
- Pest fixture: three architecture tests genuinely failed (Calculator not
  final, missing strict_types, invalid ->or() chain) and the scenario's
  --filter='custom expectation' matched no test; fixture fixed and a
  CustomExpectationTest added.
- Magento fixture: OpenSearch >=2.12 refuses to start without an admin
  password; use DISABLE_SECURITY_PLUGIN=true (which itself sets
  plugins.security.disabled - setting both is a startup error).
- Rootless fixture: mounted public/ one level above the nginx docroot so
  every request 404'd; scenario also asserted pre-Docker-20.10 kernel
  behavior (unprivileged port-80 bind refusal) - now informational.
- Symfony fixture: added the symfony.lock a Flex-managed app always has.
- Fixture default images normalized to 8.5-bookworm-v1 channel tags (one
  had drifted to a nonexistent alpine tag).
- entrypoint-lib.sh: Symfony detection accepts a symfony/framework-bundle
  composer dependency (not only symfony.lock), and fix_symfony_permissions
  creates var/cache + var/log instead of skipping when absent - mirrors
  cboxdk/init#137 where the same chicken-and-egg bug lived in cbox-init's
  detectFramework.

Local verdict: 17 passed, 2 tier-skips on standard; chromium pair green
against the chromium tier; rootless green against the rootless target.
@sylvesterdamgaard
sylvesterdamgaard merged commit f476844 into main Sep 7, 2026
6 checks passed
@sylvesterdamgaard
sylvesterdamgaard deleted the fix/framework-detection branch September 7, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant