From 005ee63009b21833d60edfc8f04907f74f9af6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20=C5=BBmijewski?= Date: Sun, 12 Apr 2020 12:25:55 +0200 Subject: [PATCH] Added support for ENGINE_MEMORY_LIMIT_BYTES Some plugins need to use more than default 1Gb and with this changes we can easily increase or decrease the limit with an environment variable. --- README.md | 15 ++++++++------- run.sh | 4 ++++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2d7573c..c2cdd2e 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,14 @@ Some tools require to be able to launch Docker containers to scan your applicati Code Quality can be configured with environment variables, here is a list: -| Name | Function | -| ----------------- | --------------------------------------------------------------------------------------------------------- | -| SOURCE_CODE | Path to the source code to scan | -| TIMEOUT_SECONDS | Custom timeout for the `codeclimate analyze` command | -| CODECLIMATE_DEBUG | Set to enable [Code Climate debug mode](https://github.com/codeclimate/codeclimate#environment-variables) | -| CODECLIMATE_DEV | Set to enable `--dev` mode which lets you run engines not known to the CLI. | -| REPORT_STDOUT | Set to print the report to `STDOUT` instead of generating the usual report file. | +| Name | Function | +| ----------------------------| --------------------------------------------------------------------------------------------------------- | +| SOURCE_CODE | Path to the source code to scan | +| TIMEOUT_SECONDS | Custom timeout for the `codeclimate analyze` command | +| CODECLIMATE_DEBUG | Set to enable [Code Climate debug mode](https://github.com/codeclimate/codeclimate#environment-variables) | +| CODECLIMATE_DEV | Set to enable `--dev` mode which lets you run engines not known to the CLI. | +| REPORT_STDOUT | Set to print the report to `STDOUT` instead of generating the usual report file. | +| ENGINE_MEMORY_LIMIT_BYTES | Set the memory limit for engines, default is 1,024,000,000 bytes. | ### Configuration diff --git a/run.sh b/run.sh index b29aebd..74b4c42 100755 --- a/run.sh +++ b/run.sh @@ -34,6 +34,7 @@ DEFAULT_FILES_PATH=${DEFAULT_FILES_PATH:-/codeclimate_defaults} CODECLIMATE_VERSION=${CODECLIMATE_VERSION:-0.85.9} CODECLIMATE_IMAGE="codeclimate/codeclimate:$CODECLIMATE_VERSION" CONTAINER_TIMEOUT_SECONDS=${TIMEOUT_SECONDS:-900} # default to 15 min +ENGINE_MEMORY_LIMIT_BYTES=${ENGINE_MEMORY_LIMIT_BYTES:-1024000000} # default 1 Gb if [ -z "$SOURCE_CODE" ] ; then echo "SOURCE_CODE env variable not set" @@ -88,10 +89,13 @@ fi # window for the analyze command. # CODECLIMATE_DEBUG env variable is optional. It enables Code Climate debug # logging. +# ENGINE_MEMORY_LIMIT_BYTES env variable is optional. It configures the default +# allocated memory with which each engine runs docker run \ --env CODECLIMATE_CODE="$SOURCE_CODE" \ --env CODECLIMATE_DEBUG="$CODECLIMATE_DEBUG" \ --env CONTAINER_TIMEOUT_SECONDS="$CONTAINER_TIMEOUT_SECONDS" \ + --env ENGINE_MEMORY_LIMIT_BYTES="$ENGINE_MEMORY_LIMIT_BYTES" \ --volume "$SOURCE_CODE":/code \ --volume /tmp/cc:/tmp/cc \ --volume /var/run/docker.sock:/var/run/docker.sock \ -- GitLab