worker 服务:启动 Celery worker 服务以处理任务队列。如下所示:
# worker service
# The Celery worker for processing the queue.
worker:
image: langgenius/dify-api:0.6.9
restart: always
environment:
CONSOLE_WEB_URL: ''
# Startup mode, 'worker' starts the Celery worker for processing the queue.
MODE: worker
# --- All the configurations below are the same as those in the 'api' service. ---
# The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`
LOG_LEVEL: INFO
# 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`.
# same as the API service
SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
# The configurations of postgres database connection.
# It is consistent with the configuration in the 'db' service below.
DB_USERNAME: postgres
DB_PASSWORD: difyai123456
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: dify
# The configurations of redis cache connection.
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_USERNAME: ''
REDIS_PASSWORD: difyai123456
REDIS_DB: 0
REDIS_USE_SSL: 'false'
# The configurations of celery broker.
CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
# The type of storage to use for storing user files. Supported values are `local` and `s3` and `azure-blob` and `google-storage`, Default: `local`
STORAGE_TYPE: local
STORAGE_LOCAL_PATH: storage
# The S3 storage configurations, only available when STORAGE_TYPE is `s3`.
S3_ENDPOINT: 'https://xxx.r2.cloudflarestorage.com'
S3_BUCKET_NAME: 'difyai'
S3_ACCESS_KEY: 'ak-difyai'
S3_SECRET_KEY: 'sk-difyai'
S3_REGION: 'us-east-1'
# The Azure Blob storage configurations, only available when STORAGE_TYPE is `azure-blob`.
AZURE_BLOB_ACCOUNT_NAME: 'difyai'
AZURE_BLOB_ACCOUNT_KEY: 'difyai'
AZURE_BLOB_CONTAINER_NAME: 'difyai-container'
AZURE_BLOB_ACCOUNT_URL: 'https://<your_account_name>.blob.core.windows.net'
# The Google storage configurations, only available when STORAGE_TYPE is `google-storage`.
GOOGLE_STORAGE_BUCKET_NAME: 'yout-bucket-name'
# if you want to use Application Default Credentials, you can leave GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64 empty.
GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64: 'your-google-service-account-json-base64-string'
# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`, `relyt`, `pgvector`.
VECTOR_STORE: weaviate
# The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`.
WEAVIATE_ENDPOINT: http://weaviate:8080
# The Weaviate API key.
WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
# The Qdrant endpoint URL. Only available when VECTOR_STORE is `qdrant`.
QDRANT_URL: http://qdrant:6333
# The Qdrant API key.
QDRANT_API_KEY: difyai123456
# The Qdrant client timeout setting.
QDRANT_CLIENT_TIMEOUT: 20
# The Qdrant client enable gRPC mode.
QDRANT_GRPC_ENABLED: 'false'
# The Qdrant server gRPC mode PORT.
QDRANT_GRPC_PORT: 6334
# Milvus configuration Only available when VECTOR_STORE is `milvus`.
# The milvus host.
MILVUS_HOST: 127.0.0.1
# The milvus host.
MILVUS_PORT: 19530
# The milvus username.
MILVUS_USER: root
# The milvus password.
MILVUS_PASSWORD: Milvus
# The milvus tls switch.
MILVUS_SECURE: 'false'
# Mail configuration, support: resend
MAIL_TYPE: ''
# default send from email address, if not specified
MAIL_DEFAULT_SEND_FROM: 'YOUR EMAIL FROM (eg: no-reply <no-reply@dify.ai>)'
SMTP_SERVER: ''
SMTP_PORT: 587
SMTP_USERNAME: ''
SMTP_PASSWORD: ''
SMTP_USE_TLS: 'true'
# the api-key for resend (https://resend.com)
RESEND_API_KEY: ''
RESEND_API_URL: https://api.resend.com
# relyt configurations
RELYT_HOST: db
RELYT_PORT: 5432
RELYT_USER: postgres
RELYT_PASSWORD: difyai123456
RELYT_DATABASE: postgres
# pgvector configurations
PGVECTOR_HOST: pgvector
PGVECTOR_PORT: 5432
PGVECTOR_USER: postgres
PGVECTOR_PASSWORD: difyai123456
PGVECTOR_DATABASE: dify
# Notion import configuration, support public and internal
NOTION_INTEGRATION_TYPE: public
NOTION_CLIENT_SECRET: you-client-secret
NOTION_CLIENT_ID: you-client-id
NOTION_INTERNAL_SECRET: you-internal-secret
# Indexing configuration
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: 1000
depends_on:
- db
- redis
volumes:
# Mount the storage directory to the container, for storing user files.
- ./volumes/app/storage:/app/api/storage
networks:
- ssrf_proxy_network
- default
# worker service
# The Celery worker for processing the queue.
worker:
image: langgenius/dify-api:0.6.9
使用名为 langgenius/dify-api
的 Docker 镜像,版本为 0.6.9
,启动 Celery worker 服务以处理任务队列。
restart: always
确保容器在任何情况下(例如崩溃、系统重启等)都自动重启。
environment:
定义容器运行时的环境变量。
CONSOLE_WEB_URL: ''
控制台 Web 应用程序的基础 URL,此处未设置值。
# Startup mode, 'worker' starts the Celery worker for processing the queue.
MODE: worker
启动模式,设置为 worker
启动 Celery worker 以处理任务队列。
# --- All the configurations below are the same as those in the 'api' service. ---
# The log level for the application. Supported values are `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL`
LOG_LEVEL: INFO
应用的日志级别,支持 DEBUG
、INFO
、WARNING
、ERROR
、CRITICAL
,这里设置为 INFO
。
# 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`.
# same as the API service
SECRET_KEY: sk-9f73s3ljTXVcMT3Blb3ljTqtsKiGHXVcMT3BlbkFJLK7U
用于安全签署会话 cookie 和加密数据库中的敏感信息的密钥。可以使用 openssl rand -base64 42
生成一个强密钥。
# The configurations of postgres database connection.
# It is consistent with the configuration in the 'db' service below.
DB_USERNAME: postgres
DB_PASSWORD: difyai123456
DB_HOST: db
DB_PORT: 5432
DB_DATABASE: dify
Postgres 数据库连接的配置。与 db
服务中的配置一致。
-
DB_USERNAME
:数据库用户名。 -
DB_PASSWORD
:数据库密码。 -
DB_HOST
:数据库主机名。 -
DB_PORT
:数据库端口。 -
DB_DATABASE
:数据库名称。
# The configurations of redis cache connection.
REDIS_HOST: redis
REDIS_PORT: 6379
REDIS_USERNAME: ''
REDIS_PASSWORD: difyai123456
REDIS_DB: 0
REDIS_USE_SSL: 'false'
Redis 缓存连接的配置。
-
REDIS_HOST
:Redis 主机名。 -
REDIS_PORT
:Redis 端口。 -
REDIS_USERNAME
:Redis 用户名。 -
REDIS_PASSWORD
:Redis 密码。 -
REDIS_DB
:使用 Redis 数据库 0。 -
REDIS_USE_SSL
:是否使用 SSL。
# The configurations of celery broker.
CELERY_BROKER_URL: redis://:difyai123456@redis:6379/1
Celery broker 的配置,使用 Redis 作为 broker,并使用 Redis 数据库 1。
# The type of storage to use for storing user files. Supported values are `local` and `s3` and `azure-blob` and `google-storage`, Default: `local`
STORAGE_TYPE: local
STORAGE_LOCAL_PATH: storage
用于存储用户文件的存储类型,支持 local
、s3
、azure-blob
和 google-storage
,默认值为 local
。
STORAGE_LOCAL_PATH
:本地存储路径。
# The S3 storage configurations, only available when STORAGE_TYPE is `s3`.
S3_ENDPOINT: 'https://xxx.r2.cloudflarestorage.com'
S3_BUCKET_NAME: 'difyai'
S3_ACCESS_KEY: 'ak-difyai'
S3_SECRET_KEY: 'sk-difyai'
S3_REGION: 'us-east-1'
S3 存储配置,仅在 STORAGE_TYPE
为 s3
时可用。
-
S3_ENDPOINT
:S3 端点 URL。 -
S3_BUCKET_NAME
:S3 存储桶名称。 -
S3_ACCESS_KEY
:S3 访问密钥。 -
S3_SECRET_KEY
:S3 密钥。 -
S3_REGION
:S3 存储区域。
# The Azure Blob storage configurations, only available when STORAGE_TYPE is `azure-blob`.
AZURE_BLOB_ACCOUNT_NAME: 'difyai'
AZURE_BLOB_ACCOUNT_KEY: 'difyai'
AZURE_BLOB_CONTAINER_NAME: 'difyai-container'
AZURE_BLOB_ACCOUNT_URL: 'https://<your_account_name>.blob.core.windows.net'
Azure Blob 存储配置,仅在 STORAGE_TYPE
为 azure-blob
时可用。
-
AZURE_BLOB_ACCOUNT_NAME
:Azure Blob 存储账户名称。 -
AZURE_BLOB_ACCOUNT_KEY
:Azure Blob 存储账户密钥。 -
AZURE_BLOB_CONTAINER_NAME
:Azure Blob 容器名称。 -
AZURE_BLOB_ACCOUNT_URL
:Azure Blob 存储账户 URL。
# The Google storage configurations, only available when STORAGE_TYPE is `google-storage`.
GOOGLE_STORAGE_BUCKET_NAME: 'your-bucket-name'
# if you want to use Application Default Credentials, you can leave GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64 empty.
GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64: 'your-google-service-account-json-base64-string'
Google 存储配置,仅在 STORAGE_TYPE
为 google-storage
时可用。
-
GOOGLE_STORAGE_BUCKET_NAME
:Google 存储桶名称。 -
GOOGLE_STORAGE_SERVICE_ACCOUNT_JSON_BASE64
:Google 服务账户 JSON 的 base64 编码字符串。如果要使用应用默认凭据,可以将其留空。
# The type of vector store to use. Supported values are `weaviate`, `qdrant`, `milvus`, `relyt`, `pgvector`.
VECTOR_STORE: weaviate
# The Weaviate endpoint URL. Only available when VECTOR_STORE is `weaviate`.
WEAVIATE_ENDPOINT: http://weaviate:8080
# The Weaviate API key.
WEAVIATE_API_KEY: WVF5YThaHlkYwhGUSmCRgsX3tD5ngdN8pkih
Weaviate 配置,仅在 VECTOR_STORE
为 weaviate
时可用。
-
WEAVIATE_ENDPOINT
:Weaviate 端点 URL。 -
WEAVIATE_API_KEY
:Weaviate API 密钥。
# The Qdrant endpoint URL. Only available when VECTOR_STORE is `qdrant`.
QDRANT_URL: http://qdrant:6333
# The Qdrant API key.
QDRANT_API_KEY: difyai123456
# The Qdrant client timeout setting.
QDRANT_CLIENT_TIMEOUT: 20
# The Qdrant client enable gRPC mode.
QDRANT_GRPC_ENABLED: 'false'
# The Qdrant server gRPC mode PORT.
QDRANT_GRPC_PORT: 6334
Qdrant 配置,仅在 VECTOR_STORE
为 qdrant
时可用。
-
QDRANT_URL
:Qdrant 端点 URL。 -
QDRANT_API_KEY
:Qdrant API 密钥。 -
QDRANT_CLIENT_TIMEOUT
:Qdrant 客户端超时设置。 -
QDRANT_GRPC_ENABLED
:启用 gRPC 模式。 -
QDRANT_GRPC_PORT
:Qdrant gRPC 服务器端口。
# Milvus configuration Only available when VECTOR_STORE is `milvus`.
# The milvus host.
MILVUS_HOST: 127.0.0.1
# The milvus port.
MILVUS_PORT: 19530
# The milvus username.
MILVUS_USER: root
# The milvus password.
MILVUS_PASSWORD: Milvus
# The milvus tls switch.
MILVUS_SECURE: 'false'
Milvus 配置,仅在 VECTOR_STORE
为 milvus
时可用。
-
MILVUS_HOST
:Milvus 主机。 -
MILVUS_PORT
:Milvus 端口。 -
MILVUS_USER
:Milvus 用户名。 -
MILVUS_PASSWORD
:Milvus 密码。 -
MILVUS_SECURE
:是否启用 TLS。
# Mail configuration, support: resend
MAIL_TYPE: ''
# default send from email address, if not specified
MAIL_DEFAULT_SEND_FROM: 'YOUR EMAIL FROM (eg: no-reply <no-reply@dify.ai>)'
SMTP_SERVER: ''
SMTP_PORT: 587
SMTP_USERNAME: ''
SMTP_PASSWORD: ''
SMTP_USE_TLS: 'true'
SMTP 端口,默认值为 587,SMTP 用户名,SMTP 密码。是否使用 TLS,默认值为 true
。
# the api-key for resend (https://resend.com)
RESEND_API_KEY: ''
RESEND_API_URL: https://api.resend.com
Resend 配置。
-
RESEND_API_KEY
:Resend API 密钥。 -
RESEND_API_URL
:Resend API URL。
# relyt configurations
RELYT_HOST: db
RELYT_PORT: 5432
RELYT_USER: postgres
RELYT_PASSWORD: difyai123456
RELYT_DATABASE: postgres
Relyt 配置。
-
RELYT_HOST
:Relyt 主机。 -
RELYT_PORT
:Relyt 端口。 -
RELYT_USER
:Relyt 用户名。 -
RELYT_PASSWORD
:Relyt 密码。 -
RELYT_DATABASE
:Relyt 数据库名称。
# pgvector configurations
PGVECTOR_HOST: pgvector
PGVECTOR_PORT: 5432
PGVECTOR_USER: postgres
PGVECTOR_PASSWORD: difyai123456
PGVECTOR_DATABASE: dify
Pgvector 配置。
-
PGVECTOR_HOST
:Pgvector 主机。 -
PGVECTOR_PORT
:Pgvector 端口。 -
PGVECTOR_USER
:Pgvector 用户名。 -
PGVECTOR_PASSWORD
:Pgvector 密码。 -
PGVECTOR_DATABASE
:Pgvector 数据库名称。
# Notion import configuration, support public and internal
NOTION_INTEGRATION_TYPE: public
NOTION_CLIENT_SECRET: you-client-secret
NOTION_CLIENT_ID: you-client-id
NOTION_INTERNAL_SECRET: you-internal-secret
Notion 导入配置,支持 public
和 internal
。
-
NOTION_INTEGRATION_TYPE
:Notion 集成类型。 -
NOTION_CLIENT_SECRET
:Notion 客户端密钥。 -
NOTION_CLIENT_ID
:Notion 客户端 ID。 -
NOTION_INTERNAL_SECRET
:Notion 内部密钥。
# Indexing configuration
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH: 1000
索引配置。
INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH
:索引最大分段令牌长度。
depends_on:
- db
- redis
依赖项配置,指定此服务依赖于 db
和 redis
服务。
volumes:
# Mount the storage directory to the container, for storing user files.
- ./volumes/app/storage:/app/api/storage
卷配置,将本地目录 ./volumes/app/storage
挂载到容器中的 /app/api/storage
目录,用于存储用户文件。
networks:
- ssrf_proxy_network
- default
网络配置,指定此服务连接到 ssrf_proxy_network
和 default
网络。