Skip to content

Fix: Bump Docker base image to PHP 8.4 to match the required PHP version - #1403

Merged
fatihalp merged 1 commit into
openclassify:masterfrom
bcurran3:patch-1
Sep 20, 2026
Merged

fatihalp merged 1 commit into
openclassify:masterfrom
bcurran3:patch-1

Conversation

@bcurran3

Copy link
Copy Markdown
Contributor

Summary

The repository declares PHP 8.4 as its requirement but the Dockerfile still pins the image to php:8.3-fpm-alpine. This mismatch breaks the Docker build. This PR bumps the base image to php:8.4-fpm-alpine to match the actual requirement.

Reasoning

  • composer.json requires "php": "^8.4"
  • README.md states "PHP 8.4+" (requirements: PHP 8.4+, Composer, Node 20+, PostgreSQL 16+)
  • The Dockerfile pins FROM php:8.3-fpm-alpine (line 1), which is too old

With the current 8.3 base, the build proceeds through composer install but then fails during composer dump-autoload, because Composer's platform_check.php enforces the version from composer.json.

Errors found during testing

PHP 8.3 (current base) — build fails

In platform_check.php line 26:
  Composer detected issues in your platform: Your Composer dependencies
  require a PHP version ">= 8.4.1". You are running 8.3.33.

Occurs at the composer dump-autoload --optimize && npm install && npm run build step (the Illuminate\Foundation\ComposerScripts::postAutoloadDump handler triggers the platform check).

PHP 8.5 — build fails (not a drop-in fix)

... docker-php-ext-install pdo pdo_pgsql mbstring exif pcntl bcmath gd opcache intl zip
Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20250925/
cp: can't stat 'modules/': No such file or directory
make: *** [Makefile:89: install-modules] Error 1

At php:8.5-fpm-alpine the extension list does not compile cleanly (the modules/ directory ends up empty), so this step fails before Composer even runs.

PHP 8.4 — build succeeds

  • docker-php-ext-install pdo pdo_pgsql mbstring exif pcntl bcmath gd opcache intl zip completes with exit code 0 on php:8.4-fpm-alpine.
  • Satisfies composer.json ^8.4 and README "PHP 8.4+".

Notes

  • php:8.4 is the minimal correct target: it satisfies the declared ^8.4 constraint and the published README requirement, and all required PHP extensions build successfully.
  • php:8.5 (referenced in the project description) is not a clean swap — it additionally requires fixing the extension build.
  • No other Dockerfile changes are needed; the rest of the build steps are unchanged.
  • The repository "About" description should be updated. It currently reads "OpenClassify is modular and advanced open source classified platform with Laravel 13 & PHP 8.5". Until the project actually uses and is compatible with PHP 8.5 (only 8.4 builds today), that should reference 8.4. Better still, the preferred change is to remove the hardcoded framework/PHP version from the description entirely — e.g. "OpenClassify is a modular and advanced open source classified platform" — keeping it generic so it doesn't need another edit on every framework/dependency bump.

Proof of concept

Screenshot attached: Ansible applying this exact one-line Dockerfile change and the role completing successfully (image built, containers healthy) — confirming the 8.4 bump is sufficient on its own for a clean build and run.

Additional changes needed behind a reverse proxy (not part of this diff)

The PHP bump is necessary but not the only thing required to get the app rendering correctly behind a TLS-terminating reverse proxy (Traefik in my case). These are deployment-side and intentionally excluded from this PR, but worth flagging:

  • Trusted proxies. The proxy forwards plain HTTP to the container, so Laravel emitted http:// asset/route URLs and the browser blocked the JS/CSS, leaving the page unstyled. docker/start.sh runs php artisan config:cache, and the framework's default TrustProxies middleware reads config('trustedproxy.proxies') (TrustProxies.php:69). Adding a small config/trustedproxy.php returning ['proxies' => env('TRUSTED_PROXIES', '*')] with TRUSTED_PROXIES=* makes the app honor X-Forwarded-Proto/X-Forwarded-Host.
  • Missing module view dirs. A fresh clone omits the empty Modules/{Admin,Demo,Location,Report,Review,Theme}/resources/views directories, which aborts php artisan view:cache at startup.
  • Vite CSS not linked. Upstream vite.config.ts sets cssCodeSplit: false; the theme CSS is emitted as a separate style.css asset that @vite(['resources/ts/app.ts']) never links, so / and /panel render unstyled even once the proxy is handled.

Context

This was found while creating an Ansible role to deploy OpenClassify for one of my projects. The build issues above were triaged and tested with AI assistance (php:8.3, php:8.4, and php:8.5 base images were each built and the failures recorded), as were the reverse-proxy/startup fixes above.

Division of labor: the code change in this PR is a single number typed by hand — 8.3 → 8.4 ✏️ (that's the whole diff, I promise). The PR write-up, plus the triage/diagnosis of the build failures and the fixes to get the app working behind a reverse proxy in my deployment, were done with AI assistance.

image

8.3 (upstream's pin): build fails at composer dump-autoload → Composer ... require a PHP version ">= 8.4.1".
@fatihalp
fatihalp merged commit 42516cf into openclassify:master Sep 20, 2026
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.

2 participants