Skip to content

Commit 9f59d63

Browse files
authored
Merge pull request #463 from continuouspipe/feature/allow-enabling-opcache-on-cli
Allow enabling opcache on CLI and enable this + tune magento2
2 parents ff8d4d0 + ce8b00a commit 9f59d63

6 files changed

Lines changed: 19 additions & 2 deletions

File tree

magento2/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,15 @@ MAGENTO_ENABLE_TRANSLATE_CACHE | If true, enable this cache type in /app/app/etc
160160
MAGENTO_ENABLE_CONFIG_WEBSERVICE_CACHE | If true, enable this cache type in /app/app/etc/env.php | true/false | true
161161
MAGENTO_ENABLE_TARGET_RULE_CACHE | If true, enable the target rule cache type in /app/app/etc/env.php. Enterprise edition only. | true/false | true
162162
MAGENTO_ENTERPRISE_EDITION | If true, this installation of magento is the enterprise edition which allows you to use the target rule cache. | true/false | false
163+
164+
The following variables have had their defaults changed from the php-nginx image so that Magento 2 runs better:
165+
166+
Variable | Description | Expected values | Default
167+
--- | --- | --- | ----
168+
PHP_MEMORY_LIMIT | The memory limit for PHP. | string | 768M
169+
PHP_MAX_EXECUTION_TIME | How long in seconds can a PHP script run for? | integer | 600
170+
PHP_OPCACHE_MAX_ACCELERATED_FILES | How many files PHP can cache into Opcache | integer | 130987
171+
PHP_REALPATH_CACHE_SIZE | How many resolved file locations PHP can cache into the realpath cache. | string | 4096K
172+
PHP_REALPATH_CACHE_TTL | How many seconds can PHP cache the resolved file locations in it's realpath cache | integer | 600
173+
PHP_OPCACHE_MEMORY_CONSUMPTION | How much memory in megabytes can opcache use? | integer | 512
174+
PHP_OPCACHE_ENABLE_CLI | Should opcache be enabled on the PHP CLI? | 0/1 | 1

magento2/usr/local/share/env/30-framework

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ export IMAGE_VERSION=${IMAGE_VERSION:-1}
55
export PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-768M}
66
export PHP_MAX_EXECUTION_TIME=${PHP_MAX_EXECUTION_TIME:-600}
77

8-
export PHP_OPCACHE_MAX_ACCELERATED_FILES=${PHP_OPCACHE_MAX_ACCELERATED_FILES:-16384}
8+
export PHP_OPCACHE_MAX_ACCELERATED_FILES=${PHP_OPCACHE_MAX_ACCELERATED_FILES:-130987}
99
export PHP_REALPATH_CACHE_SIZE=${PHP_REALPATH_CACHE_SIZE:-4096K}
1010
export PHP_REALPATH_CACHE_TTL=${PHP_REALPATH_CACHE_TTL:-600}
11-
export PHP_OPCACHE_MEMORY_CONSUMPTION=${PHP_OPCACHE_MEMORY_CONSUMPTION:-256}
11+
export PHP_OPCACHE_MEMORY_CONSUMPTION=${PHP_OPCACHE_MEMORY_CONSUMPTION:-512}
12+
export PHP_OPCACHE_ENABLE_CLI=${PHP_OPCACHE_ENABLE_CLI:1}
1213

1314
PRODUCTION_ENVIRONMENT=${PRODUCTION_ENVIRONMENT:-false}
1415
PRODUCTION_ENVIRONMENT="$(convert_to_boolean_string "$PRODUCTION_ENVIRONMENT")"

php/apache/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ PHP_MEMORY_LIMIT_CLI | The PHP Memoery Limit on the Command Line | Integers and
162162
PHP_OPCACHE_MAX_ACCELERATED_FILES | The amount of files to cache the opcodes for. | integer | 2000
163163
PHP_OPCACHE_MEMORY_CONSUMPTION | The amount of megabytes that the opcode cache is allowed to use | integer | 64
164164
PHP_OPCACHE_VALIDATE_TIMESTAMPS | If PHP should use the cache directly or first check if the file has been modified, where 0 means don't check files. This will automatically be set to 0 if DEVELOPMENT_MODE is "false" | 0/1 | 0 if DEVELOPMENT_MODE is false, 1 otherwise
165+
PHP_OPCACHE_ENABLE_CLI | Should opcache be enabled on the PHP CLI? | 0/1 | 0
165166
PHP_REALPATH_CACHE_SIZE | The amount of bytes used for the cache of fully resolved file paths | Integer and a unit (K for Kilobytes/M for Megabytes/G for Gigabytes) | 16K
166167
PHP_REALPATH_CACHE_TTL | The amount of seconds to cache the fully resolved file paths for | integer | 120
167168
DEVELOPMENT_MODE | If set to "false", composer will run with the "--no-dev" flag to not bring in development dependencies. If set to "true", development dependencies will be brought in | true/false | false

php/nginx/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ PHP_MEMORY_LIMIT_CLI | The PHP Memoery Limit on the Command Line | Integers and
171171
PHP_OPCACHE_MAX_ACCELERATED_FILES | The amount of files to cache the opcodes for. | integer | 2000
172172
PHP_OPCACHE_MEMORY_CONSUMPTION | The amount of megabytes that the opcode cache is allowed to use | integer | 64
173173
PHP_OPCACHE_VALIDATE_TIMESTAMPS | If PHP should use the cache directly or first check if the file has been modified, where 0 means don't check files. This will automatically be set to 0 if DEVELOPMENT_MODE is "false" | 0/1 | 0 if DEVELOPMENT_MODE is false, 1 otherwise
174+
PHP_OPCACHE_ENABLE_CLI | Should opcache be enabled on the PHP CLI? | 0/1 | 0
174175
PHP_REALPATH_CACHE_SIZE | The amount of bytes used for the cache of fully resolved file paths | Integer and a unit (K for Kilobytes/M for Megabytes/G for Gigabytes) | 16K
175176
PHP_REALPATH_CACHE_TTL | The amount of seconds to cache the fully resolved file paths for | integer | 120
176177
DEVELOPMENT_MODE | If set to "false", composer will run with the "--no-dev" flag to not bring in development dependencies. If set to "true", development dependencies will be brought in | true/false | false

php/shared/etc/confd/templates/php/env.ini.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ memory_limit = {{ getenv "PHP_MEMORY_LIMIT_CLI" }}
55
opcache.max_accelerated_files = {{ getenv "PHP_OPCACHE_MAX_ACCELERATED_FILES" }}
66
opcache.memory_consumption = {{ getenv "PHP_OPCACHE_MEMORY_CONSUMPTION" }}
77
opcache.validate_timestamps = {{ getenv "PHP_OPCACHE_VALIDATE_TIMESTAMPS" }}
8+
opcache.enable_cli = {{ getenv "PHP_OPCACHE_ENABLE_CLI" }}
89
realpath_cache_size = {{ getenv "PHP_REALPATH_CACHE_SIZE" }}
910
realpath_cache_ttl={{ getenv "PHP_REALPATH_CACHE_TTL" }}
1011
expose_php = Off

php/shared/usr/local/share/env/40-stack

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export PHP_MEMORY_LIMIT=${PHP_MEMORY_LIMIT:-256M}
99
export PHP_OPCACHE_MAX_ACCELERATED_FILES=${PHP_OPCACHE_MAX_ACCELERATED_FILES:-2000}
1010
export PHP_OPCACHE_MEMORY_CONSUMPTION=${PHP_OPCACHE_MEMORY_CONSUMPTION:-64}
1111
export PHP_OPCACHE_VALIDATE_TIMESTAMPS=${PHP_OPCACHE_VALIDATE_TIMESTAMPS:-1}
12+
export PHP_OPCACHE_ENABLE_CLI=${PHP_OPCACHE_ENABLE_CLI:0}
1213
export PHP_REALPATH_CACHE_SIZE=${PHP_REALPATH_CACHE_SIZE:-16K}
1314
export PHP_REALPATH_CACHE_TTL=${PHP_REALPATH_CACHE_TTL:-120}
1415

0 commit comments

Comments
 (0)