Skip to content

Commit

Permalink
Dify 0.4.9 Compatibility (#30)
Browse files Browse the repository at this point in the history
* Add Release chart action & bump chart version  (#3)

* Add helm chart release logic
* Bump chart version

* Add installation guide (#4)

* Fix env clash (#9)

* Fix ENV clashing for some corner case

* Bump chart version to 0.14.1

* Fix label in worker deployment (#12)

* Bump chart version to 0.15.0

* 0.3.8 compatibility for core components (#14)

- Fix compatibility issue with URL related ENV introduced in `0.3.8` 
  - langgenius/dify#648
  - #11

* Bump chart version to 0.16.0

* Fix postgres port and database config (#18)

- Fix port configuration when external postgres exposes port other than 5432
- Fix database conofiguration when utilizing external postgres

* Update Chart.yaml

Bump version to 0.16.1

* Update README.md

Fix grammar

* Create LICENSE

* Update README.md

Add download badge

* Update README.md

* Dify 0.4.9 support (#28)

* Add new environment variables to templates

* Update nginx routing

* Remove redundant environment vairables

* Update milvus config

* Update URL setting

* Quote environment variables

* Update README.md

* Bump chart version to 0.17.0

* Update mail config

* Remove redundant extraEnv

* Bump appVersion to 0.4.9
  • Loading branch information
BorisPolonsky authored Jan 27, 2024
1 parent 6af7b57 commit c756a04
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 85 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ helm install my-release dify/dify
- [ ] object storage
- [x] weaviate
- [ ] qdrant
- [ ] milvus
### External components that can be used by this app with proper configuration
- [x] redis
- [x] postgresql
- [x] object storage
- [x] weaviate
- [x] qdrant
- [X] milvus
4 changes: 2 additions & 2 deletions charts/dify/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ type: application
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)

version: 0.16.1
version: 0.17.0

# 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
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.3.8"
appVersion: "0.4.9"

dependencies:
- name: postgresql
Expand Down
2 changes: 1 addition & 1 deletion charts/dify/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- end -}}

{{/*
Create a default fully qualified worker name.
Create a default fully qualified web name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "dify.web.fullname" -}}
Expand Down
126 changes: 68 additions & 58 deletions charts/dify/templates/config.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ SECRET_KEY: {{ .Values.api.secretKey }}
# The base URL of console application web frontend, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_WEB_URL: {{ .Values.api.url.console | quote }}
CONSOLE_WEB_URL: {{ .Values.api.url.consoleWeb | quote }}
# The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_API_URL: {{ .Values.api.url.console | quote }}
# The URL for Service API endpointsrefers to the base URL of the current API service if api domain is
CONSOLE_API_URL: {{ .Values.api.url.consoleApi | quote }}
# The URL prefix for Service API endpoints, refers to the base URL of the current API service if api domain is
# different from console domain.
# example: http://api.dify.ai
SERVICE_API_URL: {{ .Values.api.url.api | quote }}
# The URL for Web APP api server, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_API_URL: {{ .Values.api.url.app | quote }}
# The URL for Web APP frontend, refers to the Web App base URL of WEB service if web app domain is different from
SERVICE_API_URL: {{ .Values.api.url.serviceApi | quote }}
# The URL prefix for Web APP frontend, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_WEB_URL: {{ .Values.api.url.app | quote }}
APP_WEB_URL: {{ .Values.api.url.appWeb | quote }}
# File preview or download Url prefix.
# used to display File preview or download Url to the front-end or as Multi-model inputs;
# Url is signed and has expiration time.
FILES_URL: {{ .Values.api.url.files | quote }}
# When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed.
MIGRATION_ENABLED: {{ .Values.api.migration | toString | quote }}

Expand All @@ -35,8 +35,7 @@ MIGRATION_ENABLED: {{ .Values.api.migration | toString | quote }}
# The configurations of redis connection.
# It is consistent with the configuration in the 'redis' service below.
{{- include "dify.redis.config" . }}
{{/* The configurations of session, Supported values are `sqlalchemy`. `redis`*/}}
{{- include "dify.api.session.config" . }}

# The configurations of celery broker.
{{- include "dify.celery.config" . }}
# Specifies the allowed origins for cross-origin requests to the Web API, e.g. https://dify.app or * for all origins.
Expand All @@ -54,13 +53,10 @@ CONSOLE_CORS_ALLOW_ORIGINS: '*'
# If you want to enable cross-origin support,
# you must use the HTTPS protocol and set the configuration to `SameSite=None, Secure=true, HttpOnly=true`.
#
# For **production** purposes, please set `SameSite=Lax, Secure=true, HttpOnly=true`.
COOKIE_HTTPONLY: 'true'
COOKIE_SAMESITE: 'Lax'
COOKIE_SECURE: 'false'

{{- include "dify.storage.config" . }}
{{- include "dify.vectordb.config" . }}
{{ include "dify.storage.config" . }}
{{ include "dify.vectordb.config" . }}
{{ include "dify.mail.config" . }}
# The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled.
SENTRY_DSN: ''
# The sample rate for Sentry events. Default: `1.0`
Expand All @@ -69,7 +65,6 @@ SENTRY_TRACES_SAMPLE_RATE: "1.0"
SENTRY_PROFILES_SAMPLE_RATE: "1.0"
{{- end }}


{{- define "dify.worker.config" -}}
# worker service
# The Celery worker for processing the queue.
Expand All @@ -88,13 +83,26 @@ SECRET_KEY: {{ .Values.api.secretKey }}
{{ include "dify.db.config" . }}

# The configurations of redis cache connection.
{{- include "dify.redis.config" . }}
{{ include "dify.redis.config" . }}
# The configurations of celery broker.
{{- include "dify.celery.config" . }}
{{ include "dify.celery.config" . }}

{{- include "dify.storage.config" . }}
{{ include "dify.storage.config" . }}
# The Vector store configurations.
{{- include "dify.vectordb.config" . }}
{{ include "dify.vectordb.config" . }}
{{ include "dify.mail.config" . }}
{{- end }}

{{- define "dify.web.config" -}}
# The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
CONSOLE_API_URL: {{ .Values.api.url.consoleApi }}
# The URL for Web APP api server, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
APP_API_URL: {{ .Values.api.url.appApi }}
# The DSN for Sentry
{{- end }}

{{- define "dify.db.config" -}}
Expand Down Expand Up @@ -182,36 +190,9 @@ CELERY_BROKER_URL: {{ printf "redis://:%s@%s:%v/1" .auth.password $redisHost .ma
{{- end }}
{{- end }}


{{- define "dify.api.session.config" -}}
{{/*No sqlalchemy support for now*/}}
# The configurations of session, Supported values are `sqlalchemy`. `redis`
SESSION_TYPE: redis
{{- if .Values.externalRedis.enabled }}
{{- with .Values.externalRedis }}
SESSION_REDIS_HOST: {{ .host | quote }}
SESSION_REDIS_PORT: {{ .port | toString | quote }}
SESSION_REDIS_USERNAME: ""
SESSION_REDIS_PASSWORD: {{ .password | quote }}
SESSION_REDIS_USE_SSL: {{ .useSSL | toString | quote }}
{{- end }}
{{- else if .Values.redis.enabled }}
{{- $redisHost := printf "%s-redis-master" .Release.Name -}}
{{- with .Values.redis }}
SESSION_REDIS_HOST: {{ $redisHost }}
SESSION_REDIS_PORT: {{ .master.service.ports.redis | toString | quote }}
SESSION_REDIS_USERNAME: ""
SESSION_REDIS_PASSWORD: {{ .auth.password | quote }}
SESSION_REDIS_USE_SSL: {{ .tls.enabled | toString | quote }}
{{- end }}
# use redis db 2 for session store
SESSION_REDIS_DB: "2"
{{- end }}
{{- end }}

{{- define "dify.vectordb.config" }}
{{- define "dify.vectordb.config" -}}
{{- if .Values.externalWeaviate.enabled }}
# The type of vector store to use. Supported values are `weaviate`, `qdrant`.
# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`.
VECTOR_STORE: weaviate
# The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`.
WEAVIATE_ENDPOINT: {{ .Values.externalWeaviate.endpoint | quote }}
Expand All @@ -223,25 +204,50 @@ VECTOR_STORE: qdrant
QDRANT_URL: {{ .Values.externalQdrant.endpoint }}
# The Qdrant API key.
QDRANT_API_KEY: {{ .Values.externalQdrant.apiKey }}
# The Qdrant clinet timeout setting.
QDRANT_CLIENT_TIMEOUT: 20
# The DSN for Sentry error reporting. If not set, Sentry error reporting will be disabled.
{{- else if .Values.externalMilvus.enabled}}
# Milvus configuration Only available when VECTOR_STORE is `milvus`.
VECTOR_STORE: milvus
# The milvus host.
MILVUS_HOST: {{ .Values.externalMilvus.host }}
# The milvus host.
MILVUS_PORT: {{ .Values.externalMilvus.port | toString }}
# The milvus username.
MILVUS_USER: {{ .Values.externalMilvus.user }}
# The milvus password.
MILVUS_PASSWORD: {{ .Values.externalMilvus.password }}
# The milvus tls switch.
MILVUS_SECURE: {{ .Values.externalMilvus.useTLS | toString | quote }}
{{- else if .Values.weaviate.enabled }}
# The type of vector store to use. Supported values are `weaviate`, `qdrant`.
# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`.
VECTOR_STORE: weaviate
{{- with .Values.weaviate.service }}
{{- if and (eq .type "ClusterIP") (not (eq .clusterIP "None"))}}
{{- with .Values.weaviate.service }}
{{- if and (eq .type "ClusterIP") (not (eq .clusterIP "None"))}}
# The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`.
{{/*
Pitfall: scheme (i.e.) must be supecified, or weviate client won't function as
it depends on `hostname` from urllib.parse.urlparse will be empty if schema is not specified.
*/}}
WEAVIATE_ENDPOINT: {{ printf "http://%s" .name | quote }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
# The Weaviate API key.
{{- if .Values.weaviate.authentication.apikey }}
{{- if .Values.weaviate.authentication.apikey }}
WEAVIATE_API_KEY: {{ first .Values.weaviate.authentication.apikey.allowed_keys }}
{{- end }}
{{- end }}
{{- end }}
{{- define "dify.mail.config" -}}
# Mail configuration, support: resend
MAIL_TYPE: {{ .Values.api.mail.type | quote }}
# default send from email address, if not specified
MAIL_DEFAULT_SEND_FROM: {{ .Values.api.mail.defaultSender | quote }}
# the api-key for resend (https://resend.com)
RESEND_API_KEY: {{ .Values.api.mail.resendApiKey | quote }}
RESEND_API_URL: {{ .Values.api.mail.resendApiUrl | quote }}
{{- end }}
{{- define "dify.nginx.config.proxy" }}
Expand Down Expand Up @@ -312,6 +318,10 @@ server {
proxy_pass http://{{ template "dify.api.fullname" .}}:{{ .Values.api.service.port }};
include proxy.conf;
}
location /files {
proxy_pass http://{{ template "dify.api.fullname" .}}:{{ .Values.api.service.port }};
include proxy.conf;
}
location / {
proxy_pass http://{{ template "dify.web.fullname" .}}:{{ .Values.web.service.port }};
Expand Down
6 changes: 6 additions & 0 deletions charts/dify/templates/web-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "dify.web.fullname" . }}
data:
{{- include "dify.web.config" . | nindent 2 }}
3 changes: 3 additions & 0 deletions charts/dify/templates/web-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ spec:
{{- if .Values.web.extraEnv }}
{{- toYaml .Values.web.extraEnv | nindent 8 }}
{{- end }}
envFrom:
- configMapRef:
name: {{ template "dify.web.fullname" . }}
ports:
- name: web
containerPort: 3000
Expand Down
63 changes: 39 additions & 24 deletions charts/dify/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
image:
api:
repository: langgenius/dify-api
tag: 0.3.8
tag: 0.4.9
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
Expand All @@ -15,7 +15,7 @@ image:
# - myRegistryKeySecretName
web:
repository: langgenius/dify-web
tag: 0.3.8
tag: 0.4.9
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
Expand Down Expand Up @@ -56,18 +56,31 @@ api:
labels: {}
clusterIP: ""
url:
# The base URL of console application, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
console: ''
# The URL for Service API endpoints,refers to the base URL of the current API service if api domain is
# different from console domain.
# example: http://api.dify.ai
api: ''
# The URL for Web APP, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
app: ''
# The backend URL of the console API, used to concatenate the authorization callback.
# If empty, it is the same domain. Example: https://api.console.dify.ai
consoleApi: ""
# The front-end URL of the console web, used to concatenate some front-end addresses and for CORS configuration use.
# If empty, it is the same domain. Example: https://console.dify.ai
consoleWeb: ""
# Service API Url, used to display Service API Base Url to the front-end.
# If empty, it is the same domain. Example: https://api.dify.ai
serviceApi: ""
# WebApp API backend Url, used to declare the back-end URL for the front-end API.
# If empty, it is the same domain. Example: https://app.dify.ai
appApi: ""
# WebApp Url, used to display WebAPP API Base Url to the front-end. If empty, it is the same domain. Example: https://api.app.dify.ai
appWeb: ""
# File preview or download URL prefix, used to display the file preview
# or download URL to the front-end or as a multi-modal model input;
# In order to prevent others from forging, the image preview URL is signed and has a 5-minute expiration time.
files: ""
mail:
type: ''
# default enail sender from email address, if not not given specific address
defaultSender: 'YOUR EMAIL FROM (eg: no-reply <[email protected]>)'
# the api-key for resend (https://resend.com)
resendApiKey: ''
resendApiUrl: https://api.resend.com
# When enabled, migrations will be executed prior to application startup and the application will start after the migrations have completed.
migration: true
# A secret key that is used for securely signing the session cookie and encrypting sensitive information on the database. You can generate a strong key using `openssl rand -base64 42`.
Expand Down Expand Up @@ -155,16 +168,6 @@ web:
# Apply your own Environment Variables if necessary
- name: EDITION
value: "SELF_HOSTED"
# The base URL of console application api server, refers to the Console base URL of WEB service if console domain is
# different from api or web app domain.
# example: http://cloud.dify.ai
- name: CONSOLE_API_URL
value: ''
# The URL for Web APP api server, refers to the Web App base URL of WEB service if web app domain is different from
# console or api domain.
# example: http://udify.app
- name: APP_API_URL
value: ''
service:
port: 3000
annotations: {}
Expand Down Expand Up @@ -2519,3 +2522,15 @@ externalQdrant:
enabled: false
endpoint: "https://your-qdrant-cluster-url.qdrant.tech/"
apiKey: "ak-difyai"

###################################
# External Milvus
# - these configs are only used when `externalWeaviate.enabled` is false and `externalQdrant.enabled` is true
###################################
externalMilvus:
enabled: false
host: "your-milvus.domain"
port: 19530
user: "user"
password: "Milvus"
useTLS: false

0 comments on commit c756a04

Please sign in to comment.