diff --git a/frameworks/Dify/1.12.1/Dockerfile b/frameworks/Dify/1.12.1/Dockerfile index c2d5b97788d744317eefd949b5058b1b24d674c6..c4ef8e578b006737bdbc9e84faef7f3fa461dc0d 100644 --- a/frameworks/Dify/1.12.1/Dockerfile +++ b/frameworks/Dify/1.12.1/Dockerfile @@ -52,81 +52,8 @@ COPY --from=dify_web /app/web /app/web-root COPY --from=plugin_daemon /app /app/plugin-daemon-root -RUN cat >/usr/local/bin/dify-entrypoint <<'EOF' -#!/usr/bin/env bash -set -euo pipefail - -ROLE="${ROLE:-${MODE:-api}}" - -case "$ROLE" in - api|worker|beat) - export MODE="$ROLE" - cd /app/api - exec /bin/bash /app/api-entrypoint.sh - ;; - - web) - cd /app/web-root - export PORT="${PORT:-3000}" - - if [ -x ./entrypoint.sh ]; then - exec ./entrypoint.sh - fi - - if [ -f ./server.js ]; then - exec node ./server.js - fi - - if [ -f ./targets/next/server.js ]; then - exec node ./targets/next/server.js - fi - - if [ -f ./package.json ]; then - exec npm run start - fi - - echo "Cannot find web startup file" - ls -lah /app/web-root - exit 1 - ;; - - plugin_daemon|plugin-daemon|plugin) - cd /app/plugin-daemon-root - - export SERVER_PORT="${SERVER_PORT:-5002}" - export PLUGIN_WORKING_PATH="${PLUGIN_WORKING_PATH:-/app/storage/cwd}" - export PLUGIN_STORAGE_LOCAL_ROOT="${PLUGIN_STORAGE_LOCAL_ROOT:-/app/storage}" - - mkdir -p "${PLUGIN_WORKING_PATH}" "${PLUGIN_STORAGE_LOCAL_ROOT}" - - if [ -x ./entrypoint.sh ]; then - exec ./entrypoint.sh - fi - - if [ -x ./dify-plugin-daemon ]; then - exec ./dify-plugin-daemon - fi - - if [ -x ./plugin_daemon ]; then - exec ./plugin_daemon - fi - - if [ -x ./main ]; then - exec ./main - fi - - echo "Cannot find plugin daemon executable" - ls -lah /app/plugin-daemon-root - exit 1 - ;; - - *) - echo "Unknown ROLE/MODE: $ROLE" - echo "Allowed: api, worker, beat, web, plugin_daemon" - exit 1 - ;; -esac -EOF +COPY dify-entrypoint.sh /usr/local/bin/dify-entrypoint + RUN sed -i 's/\r$//' /usr/local/bin/dify-entrypoint /app/api-entrypoint.sh \ && chmod +x /usr/local/bin/dify-entrypoint /app/api-entrypoint.sh diff --git a/frameworks/Dify/1.12.1/README.md b/frameworks/Dify/1.12.1/README.md index 5b29a1e106c4ebf4cd9fbb1faf83a4926fabf144..0f8b1854d2654913b819ee23ad7138a9a093fe53 100644 --- a/frameworks/Dify/1.12.1/README.md +++ b/frameworks/Dify/1.12.1/README.md @@ -311,3 +311,7 @@ services: 索引 schema ~~~ 变化明显 + + +# 部署配置获取 +* OpenCloudOS: https://gitee.com/OpenCloudOS/ai-agent-container/tree/master/frameworks diff --git a/frameworks/Dify/1.12.1/compose-template.yml b/frameworks/Dify/1.12.1/compose-template.yml new file mode 100644 index 0000000000000000000000000000000000000000..6711445f48c0c228e5f33e0a89f84da92f22f943 --- /dev/null +++ b/frameworks/Dify/1.12.1/compose-template.yml @@ -0,0 +1,195 @@ +name: dify-opencloudos + +x-dify-image: &dify_image oc9-dify:1.12.1 + +x-common-env: &common_env + EDITION: SELF_HOSTED + DEPLOY_ENV: PRODUCTION + CONSOLE_API_URL: http://localhost:5001 + CONSOLE_WEB_URL: http://localhost:3000 + SERVICE_API_URL: http://localhost:5001 + APP_API_URL: http://localhost:5001 + APP_WEB_URL: http://localhost:3000 + SECRET_KEY: "change-this-to-a-long-random-secret" + + DB_HOST: postgres + DB_PORT: 5432 + DB_USERNAME: postgres + DB_PASSWORD: dify_postgres_password + DB_DATABASE: dify + + REDIS_HOST: redis + REDIS_PORT: 6379 + REDIS_PASSWORD: dify_redis_password + CELERY_BROKER_URL: redis://:dify_redis_password@redis:6379/1 + + STORAGE_TYPE: local + STORAGE_LOCAL_PATH: /app/storage + + VECTOR_STORE: weaviate + WEAVIATE_ENDPOINT: http://weaviate:8080 + WEAVIATE_API_KEY: "" + + PLUGIN_DAEMON_URL: http://plugin_daemon:5002 + PLUGIN_DAEMON_KEY: "change-this-plugin-key" + PLUGIN_MAX_PACKAGE_SIZE: 52428800 + PLUGIN_PPROF_ENABLED: "false" + +services: + api: + image: *dify_image + container_name: dify-api + restart: unless-stopped + environment: + <<: *common_env + ROLE: api + MODE: api + ports: + - "5001:5001" + volumes: + - dify_storage:/app/storage + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + weaviate: + condition: service_started + plugin_daemon: + condition: service_started + networks: + - dify + + worker: + image: *dify_image + container_name: dify-worker + restart: unless-stopped + environment: + <<: *common_env + ROLE: worker + MODE: worker + volumes: + - dify_storage:/app/storage + depends_on: + - api + - redis + - postgres + networks: + - dify + + beat: + image: *dify_image + container_name: dify-beat + restart: unless-stopped + environment: + <<: *common_env + ROLE: beat + MODE: beat + volumes: + - dify_storage:/app/storage + depends_on: + - api + - redis + - postgres + networks: + - dify + + web: + image: *dify_image + container_name: dify-web + restart: unless-stopped + environment: + <<: *common_env + ROLE: web + PORT: 3000 + NEXT_PUBLIC_API_PREFIX: http://localhost:5001/console/api + NEXT_PUBLIC_PUBLIC_API_PREFIX: http://localhost:5001/api + ports: + - "3000:3000" + depends_on: + - api + networks: + - dify + + plugin_daemon: + image: *dify_image + container_name: dify-plugin-daemon + restart: unless-stopped + environment: + <<: *common_env + ROLE: plugin_daemon + SERVER_PORT: 5002 + PLUGIN_WORKING_PATH: /app/storage/cwd + PLUGIN_STORAGE_LOCAL_ROOT: /app/storage + DIFY_INNER_API_URL: http://api:5001 + DIFY_INNER_API_KEY: "change-this-plugin-key" + ports: + - "5002:5002" + - "5003:5003" + volumes: + - dify_storage:/app/storage + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + networks: + - dify + + postgres: + image: postgres:15-alpine + container_name: dify-postgres + restart: unless-stopped + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: dify_postgres_password + POSTGRES_DB: dify + volumes: + - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres -d dify"] + interval: 5s + timeout: 5s + retries: 30 + networks: + - dify + + redis: + image: redis:6-alpine + container_name: dify-redis + restart: unless-stopped + command: redis-server --requirepass dify_redis_password + volumes: + - redis_data:/data + healthcheck: + test: ["CMD", "redis-cli", "-a", "dify_redis_password", "ping"] + interval: 5s + timeout: 5s + retries: 30 + networks: + - dify + + weaviate: + image: semitechnologies/weaviate:1.19.0 + container_name: dify-weaviate + restart: unless-stopped + environment: + QUERY_DEFAULTS_LIMIT: 25 + AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: "true" + PERSISTENCE_DATA_PATH: /var/lib/weaviate + DEFAULT_VECTORIZER_MODULE: none + CLUSTER_HOSTNAME: node1 + volumes: + - weaviate_data:/var/lib/weaviate + networks: + - dify + +networks: + dify: + driver: bridge + +volumes: + dify_storage: + postgres_data: + redis_data: + weaviate_data: \ No newline at end of file diff --git a/frameworks/Dify/1.12.1/dify-entrypoint.sh b/frameworks/Dify/1.12.1/dify-entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..da7794899a2eea34907606ade5034b01d6ca2441 --- /dev/null +++ b/frameworks/Dify/1.12.1/dify-entrypoint.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROLE="${ROLE:-${MODE:-api}}" + +case "$ROLE" in + api|worker|beat) + export MODE="$ROLE" + cd /app/api + exec /bin/bash /app/api-entrypoint.sh + ;; + + web) + cd /app/web-root + export PORT="${PORT:-3000}" + + if [ -x ./entrypoint.sh ]; then + exec ./entrypoint.sh + fi + + if [ -f ./server.js ]; then + exec node ./server.js + fi + + if [ -f ./targets/next/server.js ]; then + exec node ./targets/next/server.js + fi + + if [ -f ./package.json ]; then + exec npm run start + fi + + echo "Cannot find web startup file" + ls -lah /app/web-root + exit 1 + ;; + + plugin_daemon|plugin-daemon|plugin) + cd /app/plugin-daemon-root + + export SERVER_PORT="${SERVER_PORT:-5002}" + export PLUGIN_WORKING_PATH="${PLUGIN_WORKING_PATH:-/app/storage/cwd}" + export PLUGIN_STORAGE_LOCAL_ROOT="${PLUGIN_STORAGE_LOCAL_ROOT:-/app/storage}" + + mkdir -p "${PLUGIN_WORKING_PATH}" "${PLUGIN_STORAGE_LOCAL_ROOT}" + + if [ -x ./entrypoint.sh ]; then + exec ./entrypoint.sh + fi + + if [ -x ./dify-plugin-daemon ]; then + exec ./dify-plugin-daemon + fi + + if [ -x ./plugin_daemon ]; then + exec ./plugin_daemon + fi + + if [ -x ./main ]; then + exec ./main + fi + + echo "Cannot find plugin daemon executable" + ls -lah /app/plugin-daemon-root + exit 1 + ;; + + *) + echo "Unknown ROLE/MODE: $ROLE" + echo "Allowed: api, worker, beat, web, plugin_daemon" + exit 1 + ;; +esac