From 65fccdc3cee4bc636245807d3beee0b45895fe45 Mon Sep 17 00:00:00 2001 From: vcarroy Date: Fri, 2 Aug 2024 10:33:27 +0200 Subject: [PATCH] Add opcache to symfony apps --- components/hydra-sql/files/03_base.ini | 22 +++++++++++++++++++ components/hydra-sql/kustomization.yaml | 3 +++ .../resources/hydra-sql-deployment.yaml | 10 +++++++++ resources/hydra-dispatcher/files/03_base.ini | 22 +++++++++++++++++++ resources/hydra-dispatcher/kustomization.yaml | 3 +++ .../hydra-dispatcher-deployment.yaml | 10 +++++++++ 6 files changed, 70 insertions(+) create mode 100644 components/hydra-sql/files/03_base.ini create mode 100644 resources/hydra-dispatcher/files/03_base.ini diff --git a/components/hydra-sql/files/03_base.ini b/components/hydra-sql/files/03_base.ini new file mode 100644 index 0000000..c416de0 --- /dev/null +++ b/components/hydra-sql/files/03_base.ini @@ -0,0 +1,22 @@ +[opcache] +; Determines if Zend OPCache is enabled +opcache.enable=1 + +; Determines if Zend OPCache is enabled for the CLI version of PHP +opcache.enable_cli=1 + +; The OPcache shared memory storage size. +opcache.memory_consumption=512 + +; The maximum number of keys (scripts) in the OPcache hash table. +; Only numbers between 200 and 1000000 are allowed. +opcache.max_accelerated_files=20000 + +; When disabled, you must reset the OPcache manually or restart the +; webserver for changes to the filesystem to take effect. +opcache.validate_timestamps=${OPCACHE_VALIDATE_TIMESTAMP} + +; How often (in seconds) to check file timestamps for changes to the shared +; memory storage allocation. ("1" means validate once per second, but only +; once per request. "0" means always validate) +opcache.revalidate_freq=${OPCACHE_REVALIDATE_FREQ} \ No newline at end of file diff --git a/components/hydra-sql/kustomization.yaml b/components/hydra-sql/kustomization.yaml index b0b66d5..ae964ce 100644 --- a/components/hydra-sql/kustomization.yaml +++ b/components/hydra-sql/kustomization.yaml @@ -26,3 +26,6 @@ configMapGenerator: - name: sql-login-config files: - ./files/sql_login.yaml +- name: hydra-sql-php-ini + files: + - ./files/03_base.ini diff --git a/components/hydra-sql/resources/hydra-sql-deployment.yaml b/components/hydra-sql/resources/hydra-sql-deployment.yaml index eac03b4..925fa49 100644 --- a/components/hydra-sql/resources/hydra-sql-deployment.yaml +++ b/components/hydra-sql/resources/hydra-sql-deployment.yaml @@ -55,10 +55,17 @@ spec: value: 128m - name: PHP_FPM_LOG_LEVEL value: warning + - name: OPCACHE_VALIDATE_TIMESTAMP + value: "0" + - name: OPCACHE_REVALIDATE_FREQ + value: "0" volumeMounts: - name: sql-login-config mountPath: "/app/config/sql_login_configuration/sql_login.yaml" subPath: "sql_login.yaml" + - name: hydra-sql-php-ini + mountPath: /etc/php81/conf.d/03_base.ini + subPath: 03_base.ini - name: hydra-sql-caddy image: reg.cadoles.com/cadoles/hydra-sql-base:2024.7.25-develop.1026.5bfd899 @@ -108,5 +115,8 @@ spec: - name: sql-login-config configMap: name: sql-login-config + - name: hydra-sql-php-ini + configMap: + name: hydra-sql-php-ini restartPolicy: Always diff --git a/resources/hydra-dispatcher/files/03_base.ini b/resources/hydra-dispatcher/files/03_base.ini new file mode 100644 index 0000000..c416de0 --- /dev/null +++ b/resources/hydra-dispatcher/files/03_base.ini @@ -0,0 +1,22 @@ +[opcache] +; Determines if Zend OPCache is enabled +opcache.enable=1 + +; Determines if Zend OPCache is enabled for the CLI version of PHP +opcache.enable_cli=1 + +; The OPcache shared memory storage size. +opcache.memory_consumption=512 + +; The maximum number of keys (scripts) in the OPcache hash table. +; Only numbers between 200 and 1000000 are allowed. +opcache.max_accelerated_files=20000 + +; When disabled, you must reset the OPcache manually or restart the +; webserver for changes to the filesystem to take effect. +opcache.validate_timestamps=${OPCACHE_VALIDATE_TIMESTAMP} + +; How often (in seconds) to check file timestamps for changes to the shared +; memory storage allocation. ("1" means validate once per second, but only +; once per request. "0" means always validate) +opcache.revalidate_freq=${OPCACHE_REVALIDATE_FREQ} \ No newline at end of file diff --git a/resources/hydra-dispatcher/kustomization.yaml b/resources/hydra-dispatcher/kustomization.yaml index b3441fe..7ab4a1d 100644 --- a/resources/hydra-dispatcher/kustomization.yaml +++ b/resources/hydra-dispatcher/kustomization.yaml @@ -29,3 +29,6 @@ configMapGenerator: - name: hydra-dispatcher-apps files: - apps.yaml=./files/hydra/default.yaml +- name: hydra-dispatcher-php-ini + files: + - ./files/03_base.ini \ No newline at end of file diff --git a/resources/hydra-dispatcher/resources/hydra-dispatcher-deployment.yaml b/resources/hydra-dispatcher/resources/hydra-dispatcher-deployment.yaml index 202004d..93cbcad 100644 --- a/resources/hydra-dispatcher/resources/hydra-dispatcher-deployment.yaml +++ b/resources/hydra-dispatcher/resources/hydra-dispatcher-deployment.yaml @@ -41,12 +41,19 @@ spec: value: 128m - name: PHP_FPM_MEMORY_LIMIT value: 128m + - name: OPCACHE_VALIDATE_TIMESTAMP + value: "0" + - name: OPCACHE_REVALIDATE_FREQ + value: "0" envFrom: - configMapRef: name: hydra-dispatcher-env volumeMounts: - mountPath: /app/config/hydra name: hydra-dispatcher-apps + - name: hydra-dispatcher-php-ini + mountPath: /etc/php81/conf.d/03_base.ini + subPath: 03_base.ini resources: {} securityContext: runAsNonRoot: true @@ -105,3 +112,6 @@ spec: - name: hydra-dispatcher-apps configMap: name: hydra-dispatcher-apps + - name: hydra-dispatcher-php-ini + configMap: + name: hydra-dispatcher-php-ini \ No newline at end of file