Skip to content

Enable opcache and tune PHP in the docker image - #2462

Open
lancepioch wants to merge 1 commit into
mainfrom
docker/opcache
Open

Enable opcache and tune PHP in the docker image#2462
lancepioch wants to merge 1 commit into
mainfrom
docker/opcache

Conversation

@lancepioch

Copy link
Copy Markdown
Member

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.

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
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

PHP Runtime Configuration

Layer / File(s) Summary
PHP baseline and OPcache settings
Dockerfile.base, Dockerfile.dev, docker/php/pelican.ini
Base images install OPcache, use php.ini-production, and apply 256M memory and OPcache overrides.
Runtime configuration wiring
Dockerfile, Dockerfile.dev, docker/php/pelican-pool.conf
Final images copy PHP and PHP-FPM overrides, including dynamic worker limits and worker recycling.
Startup view caching
docker/entrypoint.sh
Container startup caches Blade views after Filament optimization while excluding route and event caches.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main Docker image change: enabling OPcache and tuning PHP settings.
Description check ✅ Passed The description matches the changeset and accurately describes OPcache, php.ini, FPM pool, and boot-time view caching.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Dockerfile (1)

87-89: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Inconsistent file ownership for PHP configuration files.

The COPY commands for the custom PHP configurations are placed after the RUN 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 copied zz-pelican.ini and zz-pelican.conf files will be owned by root:root, which is inconsistent with the rest of the directory structure.

  • Dockerfile#L87-L89: Add --chown=www-data: to the COPY commands, or move them before the RUN block.
  • Dockerfile.dev#L96-L98: Add --chown=www-data: to the COPY commands, or move them before the RUN block.
♻️ 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

📥 Commits

Reviewing files that changed from the base of the PR and between 21d125d and 6032422.

📒 Files selected for processing (6)
  • Dockerfile
  • Dockerfile.base
  • Dockerfile.dev
  • docker/entrypoint.sh
  • docker/php/pelican-pool.conf
  • docker/php/pelican.ini

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