Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/dify/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.10.0
version: 0.10.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
43 changes: 43 additions & 0 deletions charts/dify/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,47 @@ commonBackendEnvs are for api and worker containers
value: http://{{ include "dify.fullname" . }}-api-svc:{{ .Values.api.service.port }}

{{- end }}
{{- end }}

{{/*
Container env assembly.

A container's `env` is a strategic-merge list keyed by `name`. Emitting the same
name twice (e.g. a var already in api.envs also set via global.extraBackendEnvs)
is tolerated by the container runtime — last value wins — but breaks the
strategic-merge diff used by `kubectl apply`, `helm upgrade`, and ArgoCD. The
helpers below assemble each container's env in the existing upstream order and
then de-duplicate, keeping the last occurrence of each name (same last-wins rule
the runtime already applied) so the effective environment is unchanged while the
rendered list stays well-formed.
*/}}
{{- define "dify.dedupeEnv" -}}
{{- $items := .items -}}
{{- $last := dict -}}
{{- range $items -}}{{- $_ := set $last .name . -}}{{- end -}}
{{- $order := list -}}
{{- range $items -}}{{- if not (has .name $order) -}}{{- $order = append $order .name -}}{{- end -}}{{- end -}}
{{- $out := list -}}
{{- range $order -}}{{- $out = append $out (index $last .) -}}{{- end -}}
{{- toYaml $out -}}
{{- end }}

{{- define "dify.backendEnvs" -}}
{{- $ctx := .ctx -}}
{{- $items := concat
(include "dify.commonEnvs" $ctx | fromYamlArray)
(include "dify.commonBackendEnvs" $ctx | fromYamlArray)
($ctx.Values.global.extraEnvs | default list)
($ctx.Values.global.extraBackendEnvs | default list)
(.componentEnvs | default list) -}}
{{- include "dify.dedupeEnv" (dict "items" $items) -}}
{{- end }}

{{- define "dify.frontendEnvs" -}}
{{- $ctx := .ctx -}}
{{- $items := concat
(include "dify.commonEnvs" $ctx | fromYamlArray)
($ctx.Values.global.extraEnvs | default list)
(.componentEnvs | default list) -}}
{{- include "dify.dedupeEnv" (dict "items" $items) -}}
{{- end }}
56 changes: 5 additions & 51 deletions charts/dify/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,7 @@ spec:
env:
- name: MODE
value: "api"
{{- include "dify.commonEnvs" . | nindent 12 }}
{{- include "dify.commonBackendEnvs" . | nindent 12 }}
{{- with .Values.global.extraEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.extraBackendEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.api.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "dify.backendEnvs" (dict "ctx" . "componentEnvs" .Values.api.envs) | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -136,17 +126,7 @@ spec:
env:
- name: MODE
value: "worker"
{{- include "dify.commonEnvs" . | nindent 12 }}
{{- include "dify.commonBackendEnvs" . | nindent 12 }}
{{- with .Values.global.extraEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.extraBackendEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.worker.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "dify.backendEnvs" (dict "ctx" . "componentEnvs" .Values.worker.envs) | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -224,17 +204,7 @@ spec:
env:
- name: MODE
value: "beat"
{{- include "dify.commonEnvs" . | nindent 12 }}
{{- include "dify.commonBackendEnvs" . | nindent 12 }}
{{- with .Values.global.extraEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.extraBackendEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.workerBeat.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "dify.backendEnvs" (dict "ctx" . "componentEnvs" .Values.workerBeat.envs) | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -309,13 +279,7 @@ spec:
image: "{{ .Values.frontend.image.repository }}:{{ coalesce .Values.frontend.image.tag .Values.global.image.tag .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.frontend.image.pullPolicy }}
env:
{{- include "dify.commonEnvs" . | nindent 12 }}
{{- with .Values.global.extraEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.frontend.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "dify.frontendEnvs" (dict "ctx" . "componentEnvs" .Values.frontend.envs) | nindent 12 }}
ports:
- name: http
containerPort: {{ .Values.frontend.containerPort }}
Expand Down Expand Up @@ -510,17 +474,7 @@ spec:
value: {{ .Values.pluginDaemon.difyInnerApiKey | quote }}
{{- else }}
{{- end }}
{{- include "dify.commonEnvs" . | nindent 12 }}
{{- include "dify.commonBackendEnvs" . | nindent 12 }}
{{- with .Values.global.extraEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.global.extraBackendEnvs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.pluginDaemon.envs }}
{{- toYaml . | nindent 12 }}
{{- end }}
{{- include "dify.backendEnvs" (dict "ctx" . "componentEnvs" .Values.pluginDaemon.envs) | nindent 12 }}
volumeMounts:
- name: plugin-daemon-storage
mountPath: /app/storage
Expand Down
Loading