diff --git a/dify/README.md b/dify/README.md deleted file mode 100644 index 24bc4a7..0000000 --- a/dify/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Dify - -- copied from https://github.com/langgenius/dify -- removed `container_name` -- removed `ports` diff --git a/dify/code/.env.example b/dify/code/.env.example index 9f2fa47..dcfc848 100644 --- a/dify/code/.env.example +++ b/dify/code/.env.example @@ -397,7 +397,7 @@ WEB_API_CORS_ALLOW_ORIGINS=* # Specifies the allowed origins for cross-origin requests to the console API, # e.g. https://cloud.dify.ai or * for all origins. CONSOLE_CORS_ALLOW_ORIGINS=* -# When the frontend and backend run on different subdomains, set COOKIE_DOMAIN to the site’s top-level domain (e.g., `example.com`). Leading dots are optional. +# When the frontend and backend run on different subdomains, set COOKIE_DOMAIN to the site's top-level domain (e.g., `example.com`). Leading dots are optional. COOKIE_DOMAIN= # When the frontend and backend run on different subdomains, set NEXT_PUBLIC_COOKIE_DOMAIN=1. NEXT_PUBLIC_COOKIE_DOMAIN= @@ -1080,7 +1080,7 @@ ALIYUN_SLS_ENDPOINT= ALIYUN_SLS_REGION= # Aliyun SLS Project Name ALIYUN_SLS_PROJECT_NAME= -# Number of days to retain workflow run logs (default: 365 days, 3650 for permanent storage) +# Number of days to retain workflow run logs (default: 365 days, 3650 for permanent storage) ALIYUN_SLS_LOGSTORE_TTL=365 # Enable dual-write to both SLS LogStore and SQL database (default: false) LOGSTORE_DUAL_WRITE_ENABLED=false @@ -1375,6 +1375,7 @@ PLUGIN_DAEMON_PORT=5002 PLUGIN_DAEMON_KEY=lYkiYYT6owG+71oLerGzA7GXCgOT++6ovaezWAjpCjf+Sjc3ZtU+qUEi PLUGIN_DAEMON_URL=http://plugin_daemon:5002 PLUGIN_MAX_PACKAGE_SIZE=52428800 +PLUGIN_MODEL_SCHEMA_CACHE_TTL=3600 PLUGIN_PPROF_ENABLED=false PLUGIN_DEBUGGING_HOST=0.0.0.0 @@ -1398,9 +1399,9 @@ PLUGIN_STDIO_BUFFER_SIZE=1024 PLUGIN_STDIO_MAX_BUFFER_SIZE=5242880 PLUGIN_PYTHON_ENV_INIT_TIMEOUT=120 -# Plugin Daemon side timeout (configure to match the API side below) +# Plugin Daemon side timeout (configure to match the API side below) PLUGIN_MAX_EXECUTION_TIMEOUT=600 -# API side timeout (configure to match the Plugin Daemon side above) +# API side timeout (configure to match the Plugin Daemon side above) PLUGIN_DAEMON_TIMEOUT=600.0 # PIP_MIRROR_URL=https://pypi.tuna.tsinghua.edu.cn/simple PIP_MIRROR_URL= @@ -1518,3 +1519,31 @@ AMPLITUDE_API_KEY= SANDBOX_EXPIRED_RECORDS_CLEAN_GRACEFUL_PERIOD=21 SANDBOX_EXPIRED_RECORDS_CLEAN_BATCH_SIZE=1000 SANDBOX_EXPIRED_RECORDS_RETENTION_DAYS=30 + + +# Redis URL used for PubSub between API and +# celery worker +# defaults to url constructed from `REDIS_*` +# configurations +PUBSUB_REDIS_URL= +# Pub/sub channel type for streaming events. +# valid options are: +# +# - pubsub: for normal Pub/Sub +# - sharded: for sharded Pub/Sub +# +# It's highly recommended to use sharded Pub/Sub AND redis cluster +# for large deployments. +PUBSUB_REDIS_CHANNEL_TYPE=pubsub +# Whether to use Redis cluster mode while running +# PubSub. +# It's highly recommended to enable this for large deployments. +PUBSUB_REDIS_USE_CLUSTERS=false + +# Whether to Enable human input timeout check task +ENABLE_HUMAN_INPUT_TIMEOUT_TASK=true +# Human input timeout check interval in minutes +HUMAN_INPUT_TIMEOUT_TASK_INTERVAL=1 + + +SANDBOX_EXPIRED_RECORDS_CLEAN_TASK_LOCK_TTL=90000 diff --git a/dify/code/docker-compose-template.yaml b/dify/code/docker-compose-template.yaml index 9659990..cb5e2c4 100644 --- a/dify/code/docker-compose-template.yaml +++ b/dify/code/docker-compose-template.yaml @@ -21,7 +21,7 @@ services: # API service api: - image: langgenius/dify-api:1.11.4 + image: langgenius/dify-api:1.12.1 restart: always environment: # Use the shared environment variables. @@ -63,7 +63,7 @@ services: # worker service # The Celery worker for processing all queues (dataset, workflow, mail, etc.) worker: - image: langgenius/dify-api:1.11.4 + image: langgenius/dify-api:1.12.1 restart: always environment: # Use the shared environment variables. @@ -102,7 +102,7 @@ services: # worker_beat service # Celery beat for scheduling periodic tasks. worker_beat: - image: langgenius/dify-api:1.11.4 + image: langgenius/dify-api:1.12.1 restart: always environment: # Use the shared environment variables. @@ -132,7 +132,7 @@ services: # Frontend web application. web: - image: langgenius/dify-web:1.11.4 + image: langgenius/dify-web:1.12.1 restart: always environment: CONSOLE_API_URL: ${CONSOLE_API_URL:-} @@ -270,7 +270,7 @@ services: # plugin daemon plugin_daemon: - image: langgenius/dify-plugin-daemon:0.5.2-local + image: langgenius/dify-plugin-daemon:0.5.3-local restart: always environment: # Use the shared environment variables. @@ -662,13 +662,14 @@ services: - "${IRIS_SUPER_SERVER_PORT:-1972}:1972" - "${IRIS_WEB_SERVER_PORT:-52773}:52773" volumes: - - ./volumes/iris:/opt/iris + - ./volumes/iris:/durable - ./iris/iris-init.script:/iris-init.script - ./iris/docker-entrypoint.sh:/custom-entrypoint.sh entrypoint: ["/custom-entrypoint.sh"] tty: true environment: TZ: ${IRIS_TIMEZONE:-UTC} + ISC_DATA_DIRECTORY: /durable/iris # Oracle vector database oracle: diff --git a/dify/code/docker-compose.middleware.yaml b/dify/code/docker-compose.middleware.yaml index 81c34fc..4a739bb 100644 --- a/dify/code/docker-compose.middleware.yaml +++ b/dify/code/docker-compose.middleware.yaml @@ -123,7 +123,7 @@ services: # plugin daemon plugin_daemon: - image: langgenius/dify-plugin-daemon:0.5.2-local + image: langgenius/dify-plugin-daemon:0.5.3-local restart: always env_file: - ./middleware.env diff --git a/dify/code/docker-compose.yaml b/dify/code/docker-compose.yaml index d8153b7..8c0136f 100644 --- a/dify/code/docker-compose.yaml +++ b/dify/code/docker-compose.yaml @@ -589,6 +589,7 @@ x-shared-env: &shared-api-worker-env PLUGIN_DAEMON_KEY: ${PLUGIN_DAEMON_KEY:-lYkiYYT6owG+71oLerGzA7GXCgOT++6ovaezWAjpCjf+Sjc3ZtU+qUEi} PLUGIN_DAEMON_URL: ${PLUGIN_DAEMON_URL:-http://plugin_daemon:5002} PLUGIN_MAX_PACKAGE_SIZE: ${PLUGIN_MAX_PACKAGE_SIZE:-52428800} + PLUGIN_MODEL_SCHEMA_CACHE_TTL: ${PLUGIN_MODEL_SCHEMA_CACHE_TTL:-3600} PLUGIN_PPROF_ENABLED: ${PLUGIN_PPROF_ENABLED:-false} PLUGIN_DEBUGGING_HOST: ${PLUGIN_DEBUGGING_HOST:-0.0.0.0} PLUGIN_DEBUGGING_PORT: ${PLUGIN_DEBUGGING_PORT:-5003} @@ -682,6 +683,12 @@ x-shared-env: &shared-api-worker-env SANDBOX_EXPIRED_RECORDS_CLEAN_GRACEFUL_PERIOD: ${SANDBOX_EXPIRED_RECORDS_CLEAN_GRACEFUL_PERIOD:-21} SANDBOX_EXPIRED_RECORDS_CLEAN_BATCH_SIZE: ${SANDBOX_EXPIRED_RECORDS_CLEAN_BATCH_SIZE:-1000} SANDBOX_EXPIRED_RECORDS_RETENTION_DAYS: ${SANDBOX_EXPIRED_RECORDS_RETENTION_DAYS:-30} + PUBSUB_REDIS_URL: ${PUBSUB_REDIS_URL:-} + PUBSUB_REDIS_CHANNEL_TYPE: ${PUBSUB_REDIS_CHANNEL_TYPE:-pubsub} + PUBSUB_REDIS_USE_CLUSTERS: ${PUBSUB_REDIS_USE_CLUSTERS:-false} + ENABLE_HUMAN_INPUT_TIMEOUT_TASK: ${ENABLE_HUMAN_INPUT_TIMEOUT_TASK:-true} + HUMAN_INPUT_TIMEOUT_TASK_INTERVAL: ${HUMAN_INPUT_TIMEOUT_TASK_INTERVAL:-1} + SANDBOX_EXPIRED_RECORDS_CLEAN_TASK_LOCK_TTL: ${SANDBOX_EXPIRED_RECORDS_CLEAN_TASK_LOCK_TTL:-90000} services: # Init container to fix permissions @@ -705,7 +712,7 @@ services: # API service api: - image: langgenius/dify-api:1.11.4 + image: langgenius/dify-api:1.12.1 restart: always environment: # Use the shared environment variables. @@ -747,7 +754,7 @@ services: # worker service # The Celery worker for processing all queues (dataset, workflow, mail, etc.) worker: - image: langgenius/dify-api:1.11.4 + image: langgenius/dify-api:1.12.1 restart: always environment: # Use the shared environment variables. @@ -786,7 +793,7 @@ services: # worker_beat service # Celery beat for scheduling periodic tasks. worker_beat: - image: langgenius/dify-api:1.11.4 + image: langgenius/dify-api:1.12.1 restart: always environment: # Use the shared environment variables. @@ -816,7 +823,7 @@ services: # Frontend web application. web: - image: langgenius/dify-web:1.11.4 + image: langgenius/dify-web:1.12.1 restart: always environment: CONSOLE_API_URL: ${CONSOLE_API_URL:-} @@ -954,7 +961,7 @@ services: # plugin daemon plugin_daemon: - image: langgenius/dify-plugin-daemon:0.5.2-local + image: langgenius/dify-plugin-daemon:0.5.3-local restart: always environment: # Use the shared environment variables. @@ -1336,13 +1343,14 @@ services: restart: always init: true volumes: - - ./volumes/iris:/opt/iris + - ./volumes/iris:/durable - ./iris/iris-init.script:/iris-init.script - ./iris/docker-entrypoint.sh:/custom-entrypoint.sh entrypoint: [ "/custom-entrypoint.sh" ] tty: true environment: TZ: ${IRIS_TIMEZONE:-UTC} + ISC_DATA_DIRECTORY: /durable/iris # Oracle vector database oracle: diff --git a/dify/code/generate_docker_compose b/dify/code/generate_docker_compose index b5c0ace..bf6c142 100755 --- a/dify/code/generate_docker_compose +++ b/dify/code/generate_docker_compose @@ -9,7 +9,7 @@ def parse_env_example(file_path): Parses the .env.example file and returns a dictionary with variable names as keys and default values as values. """ env_vars = {} - with open(file_path, "r") as f: + with open(file_path, "r", encoding="utf-8") as f: for line_number, line in enumerate(f, 1): line = line.strip() # Ignore empty lines and comments @@ -55,7 +55,7 @@ def insert_shared_env(template_path, output_path, shared_env_block, header_comme Inserts the shared environment variables block and header comments into the template file, removing any existing x-shared-env anchors, and generates the final docker-compose.yaml file. """ - with open(template_path, "r") as f: + with open(template_path, "r", encoding="utf-8") as f: template_content = f.read() # Remove existing x-shared-env: &shared-api-worker-env lines @@ -69,7 +69,7 @@ def insert_shared_env(template_path, output_path, shared_env_block, header_comme # Prepare the final content with header comments and shared env block final_content = f"{header_comments}\n{shared_env_block}\n\n{template_content}" - with open(output_path, "w") as f: + with open(output_path, "w", encoding="utf-8") as f: f.write(final_content) print(f"Generated {output_path}") diff --git a/dify/code/iris/docker-entrypoint.sh b/dify/code/iris/docker-entrypoint.sh index 067bfa0..1a3b104 100755 --- a/dify/code/iris/docker-entrypoint.sh +++ b/dify/code/iris/docker-entrypoint.sh @@ -1,15 +1,33 @@ #!/bin/bash set -e -# IRIS configuration flag file -IRIS_CONFIG_DONE="/opt/iris/.iris-configured" +# IRIS configuration flag file (stored in durable directory to persist with data) +IRIS_CONFIG_DONE="/durable/.iris-configured" + +# Function to wait for IRIS to be ready +wait_for_iris() { + echo "Waiting for IRIS to be ready..." + local max_attempts=30 + local attempt=1 + while [ "$attempt" -le "$max_attempts" ]; do + if iris qlist IRIS 2>/dev/null | grep -q "running"; then + echo "IRIS is ready." + return 0 + fi + echo "Attempt $attempt/$max_attempts: IRIS not ready yet, waiting..." + sleep 2 + attempt=$((attempt + 1)) + done + echo "ERROR: IRIS failed to start within expected time." >&2 + return 1 +} # Function to configure IRIS configure_iris() { echo "Configuring IRIS for first-time setup..." # Wait for IRIS to be fully started - sleep 5 + wait_for_iris # Execute the initialization script iris session IRIS < /iris-init.script