Conversation
PHPSpreadsheet requires ext-gd, but we only use it for data export (Xlsx Writer) without charts or images. GD is only needed for: - Chart rendering - Image manipulation in spreadsheets - Drawing objects Since we don't use these features, we can safely omit GD and use --ignore-platform-req=ext-gd in composer commands. PHPSpreadsheet maintainers decided to keep GD required (PR #3766), but recommend this workaround for advanced users who know their use case doesn't need GD. Benefits: - Reduces image size by ~9MB - Removes libpng, libjpeg, freetype dependencies - Smaller attack surface Refs: PHPOffice/PhpSpreadsheet#3766
There was a problem hiding this comment.
Pull request overview
This PR removes the GD PHP extension from the Docker image to reduce image size by approximately 9MB. Since TimeTracker only uses PHPSpreadsheet for data export (not charts or images), the GD extension is not required at runtime. The --ignore-platform-req=ext-gd flag is added to composer commands to bypass PHPSpreadsheet's platform check.
Changes:
- Removed GD extension and related system dependencies from Dockerfile
- Added
--ignore-platform-req=ext-gdflag to composer install commands in Dockerfile, CI workflow, and Makefile - Added explanatory comments documenting why GD is omitted
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Dockerfile | Removed GD extension, libpng-dev, libjpeg62-turbo-dev, and libfreetype6-dev dependencies; added comments explaining the omission; updated all three composer install commands with platform requirement flags |
| Makefile | Updated composer-install target with new platform requirement flags and improved comments |
| .github/workflows/ci.yml | Updated composer install commands in both lint and test jobs with platform requirement flags and consistent comments |
| docker compose run --rm app-dev composer install --ignore-platform-req=php --ignore-platform-req=ext-gd | ||
|
|
||
| composer-update: | ||
| docker compose run --rm app-dev composer update |
There was a problem hiding this comment.
The composer-update target should also include the --ignore-platform-req flags for consistency. When developers run "make composer-update", composer will check platform requirements and fail due to the missing ext-gd extension. Add the same flags used in composer-install: --ignore-platform-req=php --ignore-platform-req=ext-gd
| docker compose run --rm app-dev composer update | |
| docker compose run --rm app-dev composer update --ignore-platform-req=php --ignore-platform-req=ext-gd |
Summary
--ignore-platform-req=ext-gdto all composer install commandsBackground
PHPSpreadsheet decided to keep GD required even though it's only needed for:
MemoryDrawing.php- embedding imagesSince TimeTracker only uses XLSX export for data (no charts or images), we can safely ignore the platform requirement.
Changes
--ignore-platform-req=ext-gdto composer commands--ignore-platform-req=ext-gdto composer-install targetImage Size Impact
Related to #210