Refactored Dockerfile to reduce size. xDebug now a separate build stage#66
Refactored Dockerfile to reduce size. xDebug now a separate build stage#66davidjeddy wants to merge 2 commits intomainfrom
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Greptile SummaryThis PR significantly refactors the Dockerfile to reduce the final image size (~900 MB → ~350 MB) by separating build tooling from the runtime image, compiling all PHP extensions (including the previously inline Key changes:
Confidence Score: 3/5
Important Files Changed
|
| FROM compile AS core-extensions | ||
| RUN docker-php-ext-install gd intl pdo_mysql pdo_pgsql sockets && \ | ||
| strip \ | ||
| $(php-config --extension-dir)/gd.so \ | ||
| $(php-config --extension-dir)/intl.so \ | ||
| $(php-config --extension-dir)/pdo_mysql.so \ | ||
| $(php-config --extension-dir)/pdo_pgsql.so \ | ||
| $(php-config --extension-dir)/sockets.so |
There was a problem hiding this comment.
GD extension missing explicit format configuration
docker-php-ext-install gd is called without a prior docker-php-ext-configure gd step. Without explicitly configuring JPEG, FreeType, and WebP support, PHP may build GD without those format backends, depending on how the configure script auto-detects headers.
The recommended pattern (same approach used in the official Docker PHP images) is:
RUN docker-php-ext-configure gd \
--with-jpeg \
--with-freetype \
--with-webp && \
docker-php-ext-install gd intl pdo_mysql pdo_pgsql sockets && \
strip \
$(php-config --extension-dir)/gd.so \
...
The dev headers (libjpeg-turbo-dev, libpng-dev, zlib-dev) are present in the compile stage, so the configure step would succeed. The current tests.yaml only verifies that the gd module appears in php -m — it does not validate that JPEG, FreeType, or WebP are available within GD, so a silently feature-reduced build could pass CI undetected.
| RUN \ | ||
| git clone --depth 1 --branch $PHP_XDEBUG_VERSION https://github.com/xdebug/xdebug && \ | ||
| cd xdebug && \ | ||
| phpize && \ | ||
| ./configure && \ | ||
| make && make install && \ | ||
| strip $(php-config --extension-dir)/xdebug.so |
There was a problem hiding this comment.
Stripping debug symbols from a debug extension
strip is applied to xdebug.so immediately after building it. Xdebug is a debugging and profiling tool; stripping its own ELF symbols does not affect its ability to debug PHP code (xdebug works at the PHP-opcode level, not via native stack unwinding of itself), so this won't break functionality.
However, if xdebug itself ever crashes, stripped symbols will make post-mortem analysis of xdebug's own C-level crash much harder. This is a minor trade-off worth being aware of, especially since the xdebug image variant is primarily intended for development/debugging use.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
What does this PR do?
Test Plan