diff --git a/charts/shopware/templates/_helpers.tpl b/charts/shopware/templates/_helpers.tpl index d8054e2..c5f9f6d 100644 --- a/charts/shopware/templates/_helpers.tpl +++ b/charts/shopware/templates/_helpers.tpl @@ -97,6 +97,23 @@ secretAccessKeyRef: {{ $fluentBitCaddyInputPath }} {{- end -}} +{{- define "storeCaddyLogConfig" -}} +{{- if hasKey .Values.store "sidecarLogging" -}} +log { + output stdout + format json + + output file {{ include "caddyLogPath" . }} { + roll_size 10MB + roll_keep 5 + roll_keep_for 24h + } +} +{{- else -}} +log +{{- end -}} +{{- end -}} + {{ define "fluentBitConfigmap" -}} {{- if hasKey .Values.store "sidecarLogging" }} {{- $fluentBitShopwareInputPath := printf "Path %s/%s" (.Values.store.sidecarLogging.logFolder | default "/var/log") (.Values.store.sidecarLogging.logFile | default "shopware.log") -}} diff --git a/charts/shopware/templates/store_caddy_config.yaml b/charts/shopware/templates/store_caddy_config.yaml index c328007..ca0a908 100644 --- a/charts/shopware/templates/store_caddy_config.yaml +++ b/charts/shopware/templates/store_caddy_config.yaml @@ -5,21 +5,67 @@ metadata: namespace: '{{ .Release.Namespace }}' data: Caddyfile: | - :8000 -{{- if hasKey .Values.store "sidecarLogging" }} - log { - output stdout - format json +{{- if .Values.store.frankenphp.enabled }} + { + skip_install_trust + + {$CADDY_GLOBAL_OPTIONS} - output file {{ include "caddyLogPath" . }} { - roll_size 10MB - roll_keep 5 - roll_keep_for 24h + servers { + trusted_proxies static private_ranges } - } -{{ else }} - log + + frankenphp { +{{- if hasKey .Values.store.frankenphp "maxThreads" }} + max_threads {{ .Values.store.frankenphp.maxThreads }} {{- end }} +{{- if hasKey .Values.store.frankenphp "maxWaitTime" }} + max_wait_time {{ .Values.store.frankenphp.maxWaitTime }} +{{- end }} + {$FRANKENPHP_CONFIG} + } + } + + {$CADDY_EXTRA_CONFIG} + + :8000 { +{{- include "storeCaddyLogConfig" . | trim | nindent 6 }} + tracing { + span caddy + } + header { + X-Trace-Id {http.vars.trace_id} + } + request_header X-Trace-Id {http.vars.trace_id} + root * /var/www/html/public + encode gzip + + @theme path /theme/* + @phpRoute { + not path /theme/* /media/* /thumbnail/* /bundles/* + not file {path} + } + + rewrite @phpRoute index.php + + @frontController path index.php + php @frontController + + handle @theme { + @theme_file file + handle @theme_file { + file_server + } + respond 410 + } + + file_server { + hide *.php + } + } +{{- else }} + :8000 +{{- include "storeCaddyLogConfig" . | trim | nindent 4 }} route { tracing { span caddy @@ -40,3 +86,4 @@ data: encode gzip file_server } +{{- end }} diff --git a/charts/shopware/values.yaml b/charts/shopware/values.yaml index 4e439de..f5af6be 100644 --- a/charts/shopware/values.yaml +++ b/charts/shopware/values.yaml @@ -81,6 +81,11 @@ store: # Disables mounting the kubernetes service account token automountServiceAccountToken: false + frankenphp: + enabled: false + # maxThreads: 40 + # maxWaitTime: 10s + caddy: # This is the read timeout for the caddy server. Default is 60s. readTimeout: 60s