Enable opcache and tune PHP in the docker image - #2462
Conversation
The image previously ran with no opcache (the official php images do not enable it), no php.ini (defaults), and the stock FPM pool capped at pm.max_children = 5. Every request recompiled the full framework and the panel could serve at most five concurrent PHP requests. - install and enable opcache in the base image, with timestamp validation kept on so runtime plugin installs still take effect - use php.ini-production as the baseline and raise memory_limit to 256M - tune the www pool (max_children 15, max_requests 500) - cache Blade views at container start; config/route/event caches are deliberately skipped because settings live in .env and plugins register providers/routes at runtime
📝 WalkthroughWalkthroughChangesPHP Runtime Configuration
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Dockerfile (1)
87-89: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueInconsistent file ownership for PHP configuration files.
The
COPYcommands for the custom PHP configurations are placed after theRUN chown -R www-data:command that changes the ownership of the/usr/local/etc/php/and/usr/local/etc/php-fpm.d/directories. As a result, the newly copiedzz-pelican.iniandzz-pelican.conffiles will be owned byroot:root, which is inconsistent with the rest of the directory structure.
Dockerfile#L87-L89: Add--chown=www-data:to theCOPYcommands, or move them before theRUNblock.Dockerfile.dev#L96-L98: Add--chown=www-data:to theCOPYcommands, or move them before theRUNblock.♻️ Proposed refactor (using --chown)
# Configure PHP and PHP-FPM -COPY docker/php/pelican.ini /usr/local/etc/php/conf.d/zz-pelican.ini -COPY docker/php/pelican-pool.conf /usr/local/etc/php-fpm.d/zz-pelican.conf +COPY --chown=www-data:www-data docker/php/pelican.ini /usr/local/etc/php/conf.d/zz-pelican.ini +COPY --chown=www-data:www-data docker/php/pelican-pool.conf /usr/local/etc/php-fpm.d/zz-pelican.conf🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@Dockerfile` around lines 87 - 89, Update the PHP configuration COPY commands in Dockerfile lines 87-89 and Dockerfile.dev lines 96-98 to set www-data ownership using the COPY ownership option, or move those commands before the existing ownership-changing RUN blocks; apply the same ownership fix at both sites for zz-pelican.ini and zz-pelican.conf.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@Dockerfile`:
- Around line 87-89: Update the PHP configuration COPY commands in Dockerfile
lines 87-89 and Dockerfile.dev lines 96-98 to set www-data ownership using the
COPY ownership option, or move those commands before the existing
ownership-changing RUN blocks; apply the same ownership fix at both sites for
zz-pelican.ini and zz-pelican.conf.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 594b81ba-2a3e-4242-b136-da2ca73dc417
📒 Files selected for processing (6)
DockerfileDockerfile.baseDockerfile.devdocker/entrypoint.shdocker/php/pelican-pool.confdocker/php/pelican.ini
The image was running with no opcache, default php.ini, and the stock fpm pool (max 5 workers). That means every request recompiles the whole framework. This turns opcache on, uses the production php.ini with a 256M memory limit, raises the pool to 15 workers, and caches blade views on boot.