Skip to content

Commit aefbab8

Browse files
Amoifrclaude
andcommitted
Fix memory limit for large project analysis
- Set PHP memory limit to unlimited by default (-1) - Add PHP_MEMORY_LIMIT env var for user configuration - Bump version to 1.4.1 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 17a1632 commit aefbab8

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

docker/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ FROM php:8.3-cli-alpine
3838

3939
LABEL org.opencontainers.image.title="PhpQuality"
4040
LABEL org.opencontainers.image.description="PHP Static Code Analyzer - Metrics & Quality Reports"
41-
LABEL org.opencontainers.image.version="1.4.0"
41+
LABEL org.opencontainers.image.version="1.4.1"
4242
LABEL org.opencontainers.image.vendor="amoifr"
4343
LABEL org.opencontainers.image.source="https://github.com/amoifr/PhpQuality"
4444
LABEL org.opencontainers.image.authors="Pascal CESCON <pascal.cescon@gmail.com>"
@@ -59,6 +59,10 @@ RUN chmod +x /app/bin/console && \
5959
ENV APP_ENV=prod
6060
ENV APP_SECRET=docker-build-secret-change-in-production
6161

62+
# PHP memory limit (default: unlimited for large project analysis)
63+
# Override with: docker run -e PHP_MEMORY_LIMIT=512M ...
64+
ENV PHP_MEMORY_LIMIT=-1
65+
6266
# Set entrypoint
6367
COPY docker/entrypoint.sh /entrypoint.sh
6468
RUN chmod +x /entrypoint.sh

docker/entrypoint.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ set -e
66
# docker run amoifr13/phpquality analyze --source=/project/src (alias)
77
# docker run amoifr13/phpquality --source=/project/src (shorthand)
88

9+
# Memory limit configuration (default: unlimited for large project analysis)
10+
PHP_MEMORY_LIMIT="${PHP_MEMORY_LIMIT:--1}"
11+
912
# If first argument starts with -, assume it's an option for phpquality:analyze
1013
if [ "${1#-}" != "$1" ]; then
1114
set -- phpquality:analyze "$@"
@@ -14,20 +17,20 @@ fi
1417
# Support both old 'analyze' and new 'phpquality:analyze' commands
1518
if [ "$1" = "analyze" ]; then
1619
shift
17-
exec php /app/bin/console phpquality:analyze "$@"
20+
exec php -d memory_limit="$PHP_MEMORY_LIMIT" /app/bin/console phpquality:analyze "$@"
1821
fi
1922

2023
if [ "$1" = "phpquality:analyze" ]; then
2124
shift
22-
exec php /app/bin/console phpquality:analyze "$@"
25+
exec php -d memory_limit="$PHP_MEMORY_LIMIT" /app/bin/console phpquality:analyze "$@"
2326
fi
2427

2528
# If first argument is a known command, run it
2629
case "$1" in
2730
list|help|about|--version|--help|-V|-h)
28-
exec php /app/bin/console "$@"
31+
exec php -d memory_limit="$PHP_MEMORY_LIMIT" /app/bin/console "$@"
2932
;;
3033
esac
3134

3235
# Otherwise, execute the command as-is
33-
exec "$@"
36+
exec "$@"

0 commit comments

Comments
 (0)