fix: restore PHP upload limits and OPcache tuning in the production image - #3
Merged
Conversation
…mage
The FrankenPHP base image loads no php.ini at all — neither
php.ini-production nor php.ini-development — so PHP's built-in defaults
apply. Verifiable in the base image:
docker run --rm dunglas/frankenphp:1-php8.4 \
php -r 'echo ini_get("upload_max_filesize"), " ",
php_ini_loaded_file() ?: "none";'
-> 2M none
The application accepts vehicle documents up to 25 MB and images up to
10 MB, so every upload above 2 MB failed in the published image — and
failed before reaching the application's own validation, with a message
that does not name the size as the cause.
42f923d intended to fold these limits into the image when it removed
docker/uploads-prod.ini and docker/opcache-prod.ini, but no ini settings
made it into the Dockerfile. This restores both as a single
docker/php-prod.ini copied to /usr/local/etc/php/conf.d/, prefixed zz-
so the OPcache values win over docker-php-ext-opcache.ini.
Also sets display_errors=Off and expose_php=Off: Laravel switches
display_errors off itself, but only once the framework is booted — an
error before that would reach the browser with paths and source lines.
Verified in the built image: upload_max_filesize=30M, post_max_size=32M,
opcache.memory_consumption=256, display_errors and expose_php off.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The FrankenPHP base image loads no php.ini at all — neither
php.ini-productionnorphp.ini-development— so PHP's built-in defaults apply. Verifiable against the base image:docker run --rm dunglas/frankenphp:1-php8.4 \ php -r 'echo ini_get("upload_max_filesize"), " ", php_ini_loaded_file() ?: "none";' # -> 2M noneThe application accepts vehicle documents up to 25 MB (
VehicleDocumentsRelationManager::MAX_FILE_SIZE_KB) and images up to 10 MB (VehicleForm::MAX_IMAGE_SIZE_KB). In the published image every upload above 2 MB fails — and it fails before reaching the application's own validation, with a message that does not name the size as the cause ("field is required" instead of a statement about size).42f923dintended to fold these limits into the image when it removeddocker/uploads-prod.inianddocker/opcache-prod.ini, but no ini settings made it into theDockerfile.Change
Both files return as a single
docker/php-prod.ini, copied to/usr/local/etc/php/conf.d/zz-app-prod.ini. Thezz-prefix makes it load last, so the OPcache values win overdocker-php-ext-opcache.inifrom the base image.upload_max_filesize=30M,post_max_size=32M(must exceed the file limit: it covers the whole form body, not just the file)validate_timestampsdeliberately stays at its default, so a new image always serves current code without an extra cache-busting step.display_errors=Off,expose_php=Off— Laravel switchesdisplay_errorsoff itself, but only once the framework is booted; an error before that (a missing extension, say) would otherwise reach the browser with paths and source lines.CLAUDE.mddocumenteddocker/uploads-prod.inias layer 1 of the three upload limits; that reference now points at the new file and explains why the setting is needed at all.Verification
Values read out of the built image, not the source file:
upload_max_filesize30Mpost_max_size32Mopcache.memory_consumption256opcache.max_accelerated_files20000display_errorsexpose_phpFull suite: 383 passed (1222 assertions). Pint clean.
🤖 Generated with Claude Code