Skip to content

tests: increase PHP memory limit to 512M in Dockerfile#778

Merged
Strift merged 2 commits into
meilisearch:mainfrom
bpolaszek:chore/raise-memory-limit
Aug 22, 2025
Merged

tests: increase PHP memory limit to 512M in Dockerfile#778
Strift merged 2 commits into
meilisearch:mainfrom
bpolaszek:chore/raise-memory-limit

Conversation

@bpolaszek

@bpolaszek bpolaszek commented Aug 19, 2025

Copy link
Copy Markdown
Contributor

Hello there,

When running docker-compose run --rm package bash -c "composer install && composer test && composer lint && composer phpstan" I got memory_limit errors during the phpstan step (Mac M4).

I suggest to raise the default limit from 128M to 512M to avoid these errors.

Summary by CodeRabbit

  • New Features

    • Composer is now preinstalled in the container, enabling dependency management directly within the image.
  • Chores

    • PHP memory limit set to 512M to improve application stability under heavier workloads.

@coderabbitai

coderabbitai Bot commented Aug 19, 2025

Copy link
Copy Markdown

Walkthrough

Adds a PHP memory limit configuration during Docker image build and includes Composer by copying the binary from a composer:2 stage into the final image.

Changes

Cohort / File(s) Summary
Docker image configuration
Dockerfile
Creates /usr/local/etc/php/conf.d/memory-limit.ini with memory_limit = 512M and copies Composer from composer:2 to /usr/local/bin/composer.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Dev as Docker Build
    participant Base as PHP Base Image
    participant Cmp as composer:2 Stage
    participant Final as Final Image

    Dev->>Base: Start build from PHP base image
    Note right of Base: Configure PHP
    Base->>Base: Create /usr/local/etc/php/conf.d/memory-limit.ini (512M)

    Dev->>Cmp: Access composer:2 stage
    Cmp-->>Final: Copy /usr/bin/composer -> /usr/local/bin/composer
    Note over Final: Image now has PHP memory limit and Composer
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

I nibbled through the layers, hop by hop,
Set PHP’s memory—no need to stop.
Snagged Composer from a neighboring cart,
Tucked it in snug, a tidy art.
Now the build burrows swift and neat—
Carrots compiled, dependencies complete! 🥕🐇

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Dockerfile (1)

8-9: Make memory limit configurable and ensure precedence.

To keep this flexible across environments and avoid being overridden by other INIs, consider:

  • Parameterizing the value via a build arg.
  • Using a zz- prefix so it wins on load order.
  • Ensuring the conf.d directory exists and using a more robust printf.

Apply this diff within the current lines to improve robustness:

-RUN echo "memory_limit = 512M" > /usr/local/etc/php/conf.d/memory-limit.ini
+RUN set -eux; \
+    mkdir -p /usr/local/etc/php/conf.d; \
+    printf "memory_limit = %s\n" "${PHP_MEMORY_LIMIT:-512M}" > /usr/local/etc/php/conf.d/zz-memory-limit.ini

Additionally, add the following Dockerfile line above this RUN to enable configuration via build-arg:

ARG PHP_MEMORY_LIMIT=512M

You can then override at build time with:
docker build --build-arg PHP_MEMORY_LIMIT=768M .

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5e89737 and 3b186d4.

📒 Files selected for processing (1)
  • Dockerfile (1 hunks)
🔇 Additional comments (1)
Dockerfile (1)

8-9: Change is correct and aligns with PHP image conventions.

Writing a dedicated INI in /usr/local/etc/php/conf.d is the right way to set memory_limit in php:8.2. This will apply to CLI and should unblock phpstan in CI and on Apple Silicon.

@Strift

Strift commented Aug 21, 2025

Copy link
Copy Markdown
Collaborator

Hello @bpolaszek and thanks for your first contribution 🙌

We'll merge this after the tests are fixed in #780

@Strift Strift added the maintenance Anything related to maintenance (CI, tests, refactoring...) label Aug 21, 2025
@Strift Strift merged commit fe22270 into meilisearch:main Aug 22, 2025
11 checks passed
@codecov

codecov Bot commented Aug 22, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.78%. Comparing base (0078a8c) to head (be7ef50).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #778   +/-   ##
=======================================
  Coverage   89.78%   89.78%           
=======================================
  Files          59       59           
  Lines        1449     1449           
=======================================
  Hits         1301     1301           
  Misses        148      148           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bpolaszek bpolaszek deleted the chore/raise-memory-limit branch August 22, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Anything related to maintenance (CI, tests, refactoring...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants