From ef1d3fd69bd102fefb25a591e90ba12d1bf5725e Mon Sep 17 00:00:00 2001 From: Gu Date: Fri, 19 Sep 2025 15:37:01 +0800 Subject: [PATCH] translate self-hosting; structure api reference --- cn/{ => api-reference}/openapi_chat.json | 0 cn/{ => api-reference}/openapi_chatflow.json | 0 .../openapi_completion.json | 0 cn/{ => api-reference}/openapi_workflow.json | 0 .../local-source-code.mdx | 308 ++++++++++++++++++ .../start-the-frontend-docker-container.mdx | 42 +++ cn/self-hosting/platform-guides/bt-panel.mdx | 85 +++++ .../platform-guides/dify-premium.mdx | 141 ++++++++ .../quick-start/docker-compose.mdx | 183 +++++++++++ cn/self-hosting/quick-start/faqs.mdx | 57 ++++ .../troubleshooting/common-issues.mdx | 134 ++++++++ .../troubleshooting/docker-issues.mdx | 129 ++++++++ .../troubleshooting/integrations.mdx | 100 ++++++ .../troubleshooting/storage-and-migration.mdx | 157 +++++++++ docs.json | 201 ++++++++---- .../local-source-code.mdx | 308 ++++++++++++++++++ .../start-the-frontend-docker-container.mdx | 42 +++ jp/self-hosting/platform-guides/bt-panel.mdx | 85 +++++ .../platform-guides/dify-premium.mdx | 139 ++++++++ .../quick-start/docker-compose.mdx | 179 ++++++++++ jp/self-hosting/quick-start/faqs.mdx | 56 ++++ .../troubleshooting/common-issues.mdx | 131 ++++++++ .../troubleshooting/docker-issues.mdx | 128 ++++++++ .../troubleshooting/integrations.mdx | 100 ++++++ .../troubleshooting/storage-and-migration.mdx | 156 +++++++++ .../debug-and-preview/preview-and-run.mdx | 2 +- 26 files changed, 2805 insertions(+), 58 deletions(-) rename cn/{ => api-reference}/openapi_chat.json (100%) rename cn/{ => api-reference}/openapi_chatflow.json (100%) rename cn/{ => api-reference}/openapi_completion.json (100%) rename cn/{ => api-reference}/openapi_workflow.json (100%) create mode 100644 cn/self-hosting/advanced-deployments/local-source-code.mdx create mode 100644 cn/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx create mode 100644 cn/self-hosting/platform-guides/bt-panel.mdx create mode 100644 cn/self-hosting/platform-guides/dify-premium.mdx create mode 100644 cn/self-hosting/quick-start/docker-compose.mdx create mode 100644 cn/self-hosting/quick-start/faqs.mdx create mode 100644 cn/self-hosting/troubleshooting/common-issues.mdx create mode 100644 cn/self-hosting/troubleshooting/docker-issues.mdx create mode 100644 cn/self-hosting/troubleshooting/integrations.mdx create mode 100644 cn/self-hosting/troubleshooting/storage-and-migration.mdx create mode 100644 jp/self-hosting/advanced-deployments/local-source-code.mdx create mode 100644 jp/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx create mode 100644 jp/self-hosting/platform-guides/bt-panel.mdx create mode 100644 jp/self-hosting/platform-guides/dify-premium.mdx create mode 100644 jp/self-hosting/quick-start/docker-compose.mdx create mode 100644 jp/self-hosting/quick-start/faqs.mdx create mode 100644 jp/self-hosting/troubleshooting/common-issues.mdx create mode 100644 jp/self-hosting/troubleshooting/docker-issues.mdx create mode 100644 jp/self-hosting/troubleshooting/integrations.mdx create mode 100644 jp/self-hosting/troubleshooting/storage-and-migration.mdx diff --git a/cn/openapi_chat.json b/cn/api-reference/openapi_chat.json similarity index 100% rename from cn/openapi_chat.json rename to cn/api-reference/openapi_chat.json diff --git a/cn/openapi_chatflow.json b/cn/api-reference/openapi_chatflow.json similarity index 100% rename from cn/openapi_chatflow.json rename to cn/api-reference/openapi_chatflow.json diff --git a/cn/openapi_completion.json b/cn/api-reference/openapi_completion.json similarity index 100% rename from cn/openapi_completion.json rename to cn/api-reference/openapi_completion.json diff --git a/cn/openapi_workflow.json b/cn/api-reference/openapi_workflow.json similarity index 100% rename from cn/openapi_workflow.json rename to cn/api-reference/openapi_workflow.json diff --git a/cn/self-hosting/advanced-deployments/local-source-code.mdx b/cn/self-hosting/advanced-deployments/local-source-code.mdx new file mode 100644 index 00000000..79178e0e --- /dev/null +++ b/cn/self-hosting/advanced-deployments/local-source-code.mdx @@ -0,0 +1,308 @@ +--- +title: 使用源代码本地启动 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/advanced-deployments/local-source-code)。 + +## 前提条件 + +### 设置 Docker 和 Docker Compose + +> 在安装 Dify 之前,请确保您的设备符合以下最低系统要求: +> +> * CPU >= 2 核 +> * RAM >= 4 GiB + +| 操作系统 | 软件 | 说明 | +| ------------------ | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| macOS 10.14 或更高版本 | Docker Desktop | 将 Docker 虚拟机(VM)设置为至少使用 2 个虚拟 CPU(vCPU)和 8 GB 的初始内存。否则,安装可能会失败。更多信息,请参考 [Docker Desktop for Mac 安装指南](https://docs.docker.com/desktop/mac/install/)。 | +| Linux 平台 | Docker 19.03 或更高版本 Docker Compose 1.25.1 或更高版本 | 请参考 [Docker 安装指南](https://docs.docker.com/engine/install/) 和 [Docker Compose 安装指南](https://docs.docker.com/compose/install/) 了解如何分别安装 Docker 和 Docker Compose。 | +| 启用 WSL 2 的 Windows | Docker Desktop | 我们建议将源代码和绑定到 Linux 容器的其他数据存储在 Linux 文件系统中,而不是 Windows 文件系统中。更多信息,请参考 [Windows 上使用 WSL 2 后端的 Docker Desktop 安装指南](https://docs.docker.com/desktop/windows/install/#wsl-2-backend)。 | + +> 如果需要使用 OpenAI TTS,系统必须安装 `FFmpeg` 才能正常运行。更多详情,请参考:[链接](https://docs.dify.ai/getting-started/install-self-hosted/install-faq#id-14.-what-to-do-if-this-error-occurs-in-text-to-speech)。 + +### 克隆 Dify 仓库 + +运行 git 命令克隆 [Dify 仓库](https://github.com/langgenius/dify)。 + +```Bash +git clone https://github.com/langgenius/dify.git +``` + +### 使用 Docker Compose 启动中间件 + +Dify 后端服务需要一系列用于存储(如 PostgreSQL / Redis / Weaviate(如果本地不可用))和扩展能力(如 Dify 的 [sandbox](https://github.com/langgenius/dify-sandbox) 和 [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) 服务)的中间件。通过运行以下命令使用 Docker Compose 启动中间件: + +```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +``` + +*** + +## 设置后端服务 + +后端服务包括: + +1. API 服务:为前端服务和 API 访问提供 API 请求服务 +2. Worker 服务:为数据集处理、工作区、清理等异步任务提供服务 + +### 环境准备 + +需要 Python 3.12。推荐使用 [pyenv](https://github.com/pyenv/pyenv) 快速安装 Python 环境。 + +要安装额外的 Python 版本,请使用 pyenv install。 + +```Bash +pyenv install 3.12 +``` + +要切换到 "3.12" Python 环境,请使用以下命令: + +```Bash +pyenv global 3.12 +``` + +### 启动 API 服务 + +1. 导航到 `api` 目录: + + ``` + cd api + ``` + +2. 准备环境变量配置文件 + + ``` + cp .env.example .env + ``` + +3. 生成随机密钥并替换 .env 文件中的 SECRET\_KEY 值 + + ``` + awk -v key="$(openssl rand -base64 42)" '/^SECRET_KEY=/ {sub(/=.*/, "=" key)} 1' .env > temp_env && mv temp_env .env + ``` + +4. 安装依赖 + + 使用 [uv](https://docs.astral.sh/uv/getting-started/installation/) 管理依赖。 + 通过运行以下命令使用 `uv` 安装所需依赖: + + ``` + uv sync + ``` + + > 对于 macOS:使用 `brew install libmagic` 安装 libmagic。 + +5. 执行数据库迁移 + + 执行数据库迁移到最新版本: + + ``` + uv run flask db upgrade + ``` + +6. 启动 API 服务 + + ``` + uv run flask run --host 0.0.0.0 --port=5001 --debug + ``` + + 预期输出: + + ``` + * Debug mode: on + INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:5001 + INFO:werkzeug:Press CTRL+C to quit + INFO:werkzeug: * Restarting with stat + WARNING:werkzeug: * Debugger is active! + INFO:werkzeug: * Debugger PIN: 695-801-919 + ``` + +### 启动 Worker 服务 + +要从队列中消费异步任务,例如数据集文件导入和数据集文档更新,请按照以下步骤启动 Worker 服务: + +* 对于 macOS 或 Linux + + ``` + uv run celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail,ops_trace + ``` + + 如果您使用 Windows 系统启动 Worker 服务,请使用以下命令: + +* 对于 Windows + + ``` + uv run celery -A app.celery worker -P solo --without-gossip --without-mingle -Q dataset,generation,mail,ops_trace --loglevel INFO + ``` + + 预期输出: + + ``` + -------------- celery@bwdeMacBook-Pro-2.local v5.4.0 (opalescent) + --- ***** ----- + -- ******* ---- macOS-15.4.1-arm64-arm-64bit 2025-04-28 17:07:14 + - *** --- * --- + - ** ---------- [config] + - ** ---------- .> app: app_factory:0x1439e8590 + - ** ---------- .> transport: redis://:**@localhost:6379/1 + - ** ---------- .> results: postgresql://postgres:**@localhost:5432/dify + - *** --- * --- .> concurrency: 1 (gevent) + -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) + --- ***** ----- + -------------- [queues] + .> dataset exchange=dataset(direct) key=dataset + .> generation exchange=generation(direct) key=generation + .> mail exchange=mail(direct) key=mail + .> ops_trace exchange=ops_trace(direct) key=ops_trace + + [tasks] + . schedule.clean_embedding_cache_task.clean_embedding_cache_task + . schedule.clean_messages.clean_messages + . schedule.clean_unused_datasets_task.clean_unused_datasets_task + . schedule.create_tidb_serverless_task.create_tidb_serverless_task + . schedule.mail_clean_document_notify_task.mail_clean_document_notify_task + . schedule.update_tidb_serverless_status_task.update_tidb_serverless_status_task + . tasks.add_document_to_index_task.add_document_to_index_task + . tasks.annotation.add_annotation_to_index_task.add_annotation_to_index_task + . tasks.annotation.batch_import_annotations_task.batch_import_annotations_task + . tasks.annotation.delete_annotation_index_task.delete_annotation_index_task + . tasks.annotation.disable_annotation_reply_task.disable_annotation_reply_task + . tasks.annotation.enable_annotation_reply_task.enable_annotation_reply_task + . tasks.annotation.update_annotation_to_index_task.update_annotation_to_index_task + . tasks.batch_clean_document_task.batch_clean_document_task + . tasks.batch_create_segment_to_index_task.batch_create_segment_to_index_task + . tasks.clean_dataset_task.clean_dataset_task + . tasks.clean_document_task.clean_document_task + . tasks.clean_notion_document_task.clean_notion_document_task + . tasks.deal_dataset_vector_index_task.deal_dataset_vector_index_task + . tasks.delete_account_task.delete_account_task + . tasks.delete_segment_from_index_task.delete_segment_from_index_task + . tasks.disable_segment_from_index_task.disable_segment_from_index_task + . tasks.disable_segments_from_index_task.disable_segments_from_index_task + . tasks.document_indexing_sync_task.document_indexing_sync_task + . tasks.document_indexing_task.document_indexing_task + . tasks.document_indexing_update_task.document_indexing_update_task + . tasks.duplicate_document_indexing_task.duplicate_document_indexing_task + . tasks.enable_segments_to_index_task.enable_segments_to_index_task + . tasks.mail_account_deletion_task.send_account_deletion_verification_code + . tasks.mail_account_deletion_task.send_deletion_success_task + . tasks.mail_email_code_login.send_email_code_login_mail_task + . tasks.mail_invite_member_task.send_invite_member_mail_task + . tasks.mail_reset_password_task.send_reset_password_mail_task + . tasks.ops_trace_task.process_trace_tasks + . tasks.recover_document_indexing_task.recover_document_indexing_task + . tasks.remove_app_and_related_data_task.remove_app_and_related_data_task + . tasks.remove_document_from_index_task.remove_document_from_index_task + . tasks.retry_document_indexing_task.retry_document_indexing_task + . tasks.sync_website_document_indexing_task.sync_website_document_indexing_task + + 2025-04-28 17:07:14,681 INFO [connection.py:22] Connected to redis://:**@localhost:6379/1 + 2025-04-28 17:07:14,684 INFO [mingle.py:40] mingle: searching for neighbors + 2025-04-28 17:07:15,704 INFO [mingle.py:49] mingle: all alone + 2025-04-28 17:07:15,733 INFO [worker.py:175] celery@bwdeMacBook-Pro-2.local ready. + 2025-04-28 17:07:15,742 INFO [pidbox.py:111] pidbox: Connected to redis://:**@localhost:6379/1. + ``` + +*** + +## 设置 Web 服务 + +启动用于前端页面的 web 服务。 + +### 环境准备 + +要启动 web 前端服务,需要 [Node.js v22 (LTS)](http://nodejs.org/) 和 [PNPM v10](https://pnpm.io/)。 + +* 安装 NodeJS + + 请访问 [https://nodejs.org/en/download](https://nodejs.org/en/download) 并选择适合您操作系统的 v18.x 或更高版本的安装包。推荐使用 LTS 版本进行常规使用。 + +* 安装 PNPM + + 按照 [安装指南](https://pnpm.io/installation) 安装 PNPM。或者直接使用 `npm` 运行以下命令安装 `pnpm`。 + + ``` + npm i -g pnpm + ``` + +### 启动 Web 服务 + +1. 进入 web 目录 + + ``` + cd web + ``` + +2. 安装依赖 + + ``` + pnpm install --frozen-lockfile + ``` + +3. 准备环境变量配置文件 + + 在当前目录中创建一个名为 `.env.local` 的文件,并从 `.env.example` 复制内容。根据您的需求修改这些环境变量的值: + + ``` + # For production release, change this to PRODUCTION + NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT + # The deployment edition, SELF_HOSTED or CLOUD + NEXT_PUBLIC_EDITION=SELF_HOSTED + # 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/api + NEXT_PUBLIC_API_PREFIX=http://localhost:5001/console/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/api + NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api + + # SENTRY + NEXT_PUBLIC_SENTRY_DSN= + NEXT_PUBLIC_SENTRY_ORG= + NEXT_PUBLIC_SENTRY_PROJECT= + ``` + +4. 构建 web 服务 + + ``` + pnpm build + ``` + +5. 启动 web 服务 + + ``` + pnpm start + ``` + + 预期输出: + + ``` + ▲ Next.js 15 + - Local: http://localhost:3000 + - Network: http://0.0.0.0:3000 + + ✓ Starting... + ✓ Ready in 73ms + ``` + +### 访问 Dify + +通过浏览器访问 [http://127.0.0.1:3000](http://127.0.0.1:3000/) 即可享受 Dify 所有激动人心的功能。 + +干杯!🍻 + +{/* + Contributing Section + DO NOT edit this section! + It will be automatically generated by the script. + */} + +*** + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/zh-hans/getting-started/install-self-hosted/local-source-code.mdx) | [提交问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) diff --git a/cn/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx b/cn/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx new file mode 100644 index 00000000..f877dc97 --- /dev/null +++ b/cn/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx @@ -0,0 +1,42 @@ +```mdx +--- +title: 单独启动前端 Docker 容器 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/advanced-deployments/start-the-frontend-docker-container)。 + +在单独开发后端时,您可能只需要从源代码启动后端服务,而无需在本地构建和启动前端。在这种情况下,您可以通过拉取 Docker 镜像并运行容器来直接启动前端服务。以下是具体步骤: + +#### 从 DockerHub 拉取前端服务的 Docker 镜像: + +```Bash +docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest +``` + +#### 从源代码构建 Docker 镜像 + +1. 构建前端镜像 + + ``` + cd web && docker build . -t dify-web + ``` + +2. 启动前端镜像 + + ``` + docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 dify-web + ``` + +3. 当控制台域和 Web 应用域不同时,可以分别设置 CONSOLE_URL 和 APP_URL +4. 要在本地访问,可以访问 [http://127.0.0.1:3000](http://127.0.0.1:3000/) + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[Edit this page](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/start-the-frontend-docker-container.mdx) | [Report an issue](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) +``` \ No newline at end of file diff --git a/cn/self-hosting/platform-guides/bt-panel.mdx b/cn/self-hosting/platform-guides/bt-panel.mdx new file mode 100644 index 00000000..396ad051 --- /dev/null +++ b/cn/self-hosting/platform-guides/bt-panel.mdx @@ -0,0 +1,85 @@ +--- +title: 使用 aaPanel 部署 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/platform-guides/bt-panel)。 + + +## 前提条件 + +> 在安装 Dify 之前,请确保您的机器满足以下最低系统要求: +> +> * CPU >= 2 核 +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + +
操作系统软件说明
Linux 平台 +

aaPanel 7.0.11 或更高版本

+
有关如何安装 aaPanel 的更多信息,请参考 aaPanel 安装指南
+## 部署 + +1. 登录 aaPanel 并在菜单栏中点击 `Docker` + +2. 首次使用时会提示安装 `Docker` 和 `Docker Compose` 服务,点击立即安装。如果已经安装,请忽略。 + +3. 安装完成后,在 `One-Click Install` 中找到 `Dify` 并点击 `install` + +4. 配置域名、端口等基本信息以完成安装 +> \[!IMPORTANT] +> +> 域名为可选项,如果填写了域名,可以通过 [网站]--> [代理项目] 进行管理,填写域名后无需勾选 [允许外部访问],否则需要勾选后才能访问 + +5. 安装完成后,在浏览器中输入域名或 IP+ 端口访问。 +- 名称:应用名称,默认 `Dify-characters` +- 版本选择:默认 `latest` +- 域名:如需直接通过域名访问,请配置域名并将域名解析到服务器 +- 允许外部访问:如需通过 `IP+Port` 访问,请勾选。如已设置域名,请不要勾选此项。 +- 端口:默认 `8088`,可自行修改 + +6. 提交后,面板将自动初始化应用,大约需要 `1-3` 分钟。初始化完成后即可访问。 + +### 访问 Dify + +访问管理员初始化页面设置管理员账户: + +```bash +# 如果您已设置域名 +http://yourdomain/install + +# 如果您选择通过 `IP+Port` 访问 +http://your_server_ip:8088/install +``` + +Dify 网页界面地址: + +```bash +# 如果您已设置域名 +http://yourdomain/ + +# 如果您选择通过 `IP+Port` 访问 +http://your_server_ip:8088/ +``` + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/bt-panel.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/cn/self-hosting/platform-guides/dify-premium.mdx b/cn/self-hosting/platform-guides/dify-premium.mdx new file mode 100644 index 00000000..9c380c05 --- /dev/null +++ b/cn/self-hosting/platform-guides/dify-premium.mdx @@ -0,0 +1,141 @@ +--- +title: AWS 上的 Dify Premium +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/platform-guides/dify-premium)。 + +Dify Premium 是我们的 AWS AMI 产品,支持自定义品牌,可一键部署到您的 AWS VPC 作为 EC2 实例。前往 [AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-t22mebxzwjhu6) 进行订阅。它在以下几种场景中很有用: + +* 您是中小型企业,希望创建一个或几个应用程序,并且关心数据驻留问题。 +* 您对 [Dify Cloud](https://cloud.dify.ai) 感兴趣,但您的用例需要比 [定价计划](https://dify.ai/pricing) 支持的更多资源。 +* 您希望在组织内采用 Dify Enterprise 之前运行概念验证。 + +## 设置 + +如果这是您首次访问 Dify,请输入管理员初始化密码(设置为您的 EC2 实例 ID)来开始设置过程。 + +AMI 部署后,通过 EC2 控制台中找到的实例公共 IP 访问 Dify(默认使用 HTTP 端口 80)。 + +## 升级 + +在 EC2 实例中,运行以下命令: + +``` +git clone https://github.com/langgenius/dify.git /tmp/dify +mv -f /tmp/dify/docker/* /dify/ +rm -rf /tmp/dify +docker-compose down +docker-compose pull +docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d +``` + + + +> 本节描述将较旧的社区版迁移到 Dify v1.0.0+。对于 Dify Premium 或社区版到此特定迁移范围之后版本的一般升级,请参考各自的主要升级说明。 + +升级过程包括以下步骤: + +1. 备份您的数据 +2. 迁移插件 +3. 升级主要的 dify 项目 + +### 1. 备份数据 + +1.1 执行 `cd` 命令导航到您的 Dify 项目目录并创建备份分支。 + +1.2 运行以下命令备份您的 docker-compose YAML 文件(可选)。 + +```bash +cd docker +cp docker-compose.yaml docker-compose.yaml.$(date +%s).bak +``` + +1.3 运行命令停止 docker 服务,然后在 Docker 目录中执行备份数据命令。 + +```bash +docker compose down +tar -cvf volumes-$(date +%s).tgz volumes +``` + +### 2. 升级版本 + +`v1.0.0` 支持通过 Docker Compose 部署。导航到您的 Dify 项目路径并运行以下命令升级到 Dify 版本: + +```bash +git checkout 1.0.0 # 切换到 1.0.0 分支 +cd docker +docker compose -f docker-compose.yaml up -d +``` + +### 3. 将工具迁移到插件 + +> **关于命令执行和包管理的重要说明(针对 v1.0.0 迁移):** +> * **默认容器名称:** `docker exec` 命令示例使用 `docker-api-1`。如果您的 API 容器有不同的名称或 ID(您可以使用 `docker ps` 找到),请相应调整命令。 +> * **Python 包管理器(`uv` vs. `poetry`):** + * Dify 从版本 [v1.3.0](https://github.com/langgenius/dify/releases/tag/1.3.0) 开始将 Python 包管理器从 `poetry` 切换到 `uv` 以提高性能。对于 Dify v1.3.0 或更新版本的一般操作,标准命令是 `uv run flask ...`。 + * **本节专门针对升级到 Dify v1.0.0。** 在 Dify v1.0.0 到(但不包括)v1.3.0 期间,`poetry` 是包管理器。因此,下面示例中的 `flask` 命令正确地使用 `poetry run ...`。代码示例首先在注释中强调当前的 `uv迁移范围相关的 `poetry` 命令。 + +此步骤的目的是自动迁移之前在社区版中使用的工具和模型供应商,并将它们安装到新的插件环境中。 + +1. 运行 `docker ps` 命令检查 API 容器名称或 ID。默认通常是 `docker-api-1`。 + +示例: + +```bash +docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +417241cd**** nginx:latest "sh -c 'cp /docker-e…" 3 hours ago Up 3 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp docker-nginx-1 +f84aa773**** langgenius/dify-api:1.0.0 "/bin/bash /entrypoi…" 3 hours ago Up 3 hours 5001/tcp docker-worker-1 +a3cb19c2**** langgenius/dify-api:1.0.0 "/bin/bash /entrypoi…" 3 hours ago Up 3 hours 5001/tcp docker-api-1 +``` + +运行命令 `docker exec -it docker-api-1 bash` 进入容器终端(如果您的容器名称不同,请使用相应的名称),然后运行: + +```bash +# 对于 Dify v1.3.0+ 环境,标准命令是 'uv run ...'。 +uv run flask extract-plugins --workers=20 +# +# 如果此处描述的社区版部分的目标迁移版本是 Dify v1.0.0 到(但不包括)v1.3.0,请使用 'poetry': +# poetry run flask extract-plugins --workers=20 +``` + +> 如果按照此 v1.0.0 迁移指南尝试执行命令时发生错误(例如,找不到 `uv` 或 `poetry`),请确保服务器上正确设置了该版本的原始先决条件的 `poetry` 环境。如果终端在运行 `poetry` 命令后要求输入,请按 **"Enter"** 键跳过。 + +此命令将提取环境中当前使用的所有模型和工具。workers 参数控制提取过程中使用的并行进程数,可根据需要调整。命令运行后,将生成一个 `plugins.jsonl` 文件,包含当前 Dify 实例中所有工作区的插件信息。 + +确保您的网络可以访问公共互联网并支持访问:`https://marketplace.dify.ai`。在 `docker-api-1` 容器中继续运行以下命令: + +```bash +# 对于 Dify v1.3.0+ 环境,标准命令是 'uv run ...'。 +uv run flask install-plugins --workers=2 +# +# 如果此处描述的社区版部分的目标迁移版本是 Dify v1.0.0 到(但不包括)v1.3.0,请使用 'poetry': +# poetry run flask install-plugins --workers=2 +``` + +此命令将下载并安装所有必要的插件到最新的社区版中。当终端显示 `Install plugins completed.` 时,迁移完成。 + + + +## 自定义 + +就像自托管部署一样,您可以根据需要修改 EC2 实例中 `.env` 下的环境变量。然后,使用以下命令重启 Dify: + +```bash +docker-compose down +docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d +``` + +## WebApp 标志和品牌自定义 + +您可以在设置下的**自定义**中启用此功能,启用**移除 Powered by Dify**并上传您自己的标志。 + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-premium.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/cn/self-hosting/quick-start/docker-compose.mdx b/cn/self-hosting/quick-start/docker-compose.mdx new file mode 100644 index 00000000..f41ba903 --- /dev/null +++ b/cn/self-hosting/quick-start/docker-compose.mdx @@ -0,0 +1,183 @@ +--- +title: Docker Compose +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/quick-start/docker-compose)。 + + +## 先决条件 + +> 在安装 Dify 之前,请确保您的机器满足以下最低系统要求: +> +> * CPU >= 2 Core +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + + + + + + + + + + + +
操作系统软件说明
macOS 10.14 或更高版本Docker Desktop将 Docker 虚拟机 (VM) 设置为使用至少 2 个虚拟 CPU (vCPU) 和 8 GB 初始内存。否则,安装可能会失败。更多信息,请参阅 Mac 版 Docker Desktop 安装指南
Linux 平台 +

Docker 19.03 或更高版本

+

Docker Compose 1.28 或更高版本

+
请分别参阅 Docker 安装指南Docker Compose 安装指南,了解如何安装 Docker 和 Docker Compose 的更多信息。
启用了 WSL 2 的 WindowsDocker Desktop我们建议将源代码和绑定到 Linux 容器的其他数据存储在 Linux 文件系统中,而不是 Windows 文件系统中。更多信息,请参阅 在 Windows 上使用 WSL 2 后端的 Docker Desktop 安装指南。
+ +### 克隆 Dify + +将 Dify 源代码克隆到本地机器: + +```bash +git clone --branch "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r .tag_name)" https://github.com/langgenius/dify.git +``` + +### 启动 Dify + +1. 导航到 Dify 源代码中的 Docker 目录 + + ```bash + cd dify/docker + ``` +2. 复制环境配置文件 + + ```bash + cp .env.example .env + ``` +3. 启动 Docker 容器 + + 根据您系统上的 Docker Compose 版本选择适当的命令来启动容器。您可以使用 `$ docker compose version` 命令检查版本,并参考 [Docker 文档](https://docs.docker.com/compose/install/) 获取更多信息: + + * 如果您使用 Docker Compose V2,使用以下命令: + + ```bash + docker compose up -d + ``` + + * 如果您使用 Docker Compose V1,使用以下命令: + + ```bash + docker-compose up -d + ``` + +执行命令后,您应该看到类似以下的输出,显示所有容器的状态和端口映射: + +```bash +[+] Running 11/11 + ✔ Network docker_ssrf_proxy_network Created 0.1s + ✔ Network docker_default Created 0.0s + ✔ Container docker-redis-1 Started 2.4s + ✔ Container docker-ssrf_proxy-1 Started 2.8s + ✔ Container docker-sandbox-1 Started 2.7s + ✔ Container docker-web-1 Started 2.7s + ✔ Container docker-weaviate-1 Started 2.4s + ✔ Container docker-db-1 Started 2.7s + ✔ Container docker-api-1 Started 6.5s + ✔ Container docker-worker-1 Started 6.4s + ✔ Container docker-nginx-1 Started 7.1s +``` + +最后,检查所有容器是否成功运行: + +```bash +docker compose ps +``` + +这包括 3 个核心服务:`api / worker / web`,以及 6 个依赖组件:`weaviate / db / redis / nginx / ssrf_proxy / sandbox`。 + +```bash +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +docker-api-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" api About a minute ago Up About a minute 5001/tcp +docker-db-1 postgres:15-alpine "docker-entrypoint.s…" db About a minute ago Up About a minute (healthy) 5432/tcp +docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx About a minute ago Up About a minute 0.0.0.0:.0.0.0:443->443/tcp, :::443->443/tcp +docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis About a minute ago Up About a minute (healthy) 6379/tcp +docker-sandbox-1 langgenius/dify-sandbox:0.2.1 "/main" sandbox About a minute ago Up About a minute +docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy About a minute ago Up About a minute 3128/tcp +docker-weaviate-1 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" weaviate About a minute ago Up About a minute +docker-web-1 langgenius/dify-web:0.6.13 "/bin/sh ./entrypoin…" web About a minute ago Up About a minute 3000/tcp +docker-worker-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" worker About a minute ago Up About a minute 5001/tcp +``` + +通过这些步骤,您应该能够成功安装 Dify。 + +### 升级 Dify + +进入 Dify 源代码的 docker 目录并执行以下命令: + +```bash +cd dify/docker +docker compose down +git pull origin main +docker compose pull +docker compose up -d +``` + +#### 同步环境变量配置(重要) + +* 如果 `.env.example` 文件已更新,请确保相应地修改您的本地 `.env` 文件。 +* 根据需要检查和修改 `.env` 文件中的配置项,确保它们与您的实际环境匹配。您可能需要将 `.env.example` 中的任何新变量添加到您的 `.env` 文件中,并更新任何已更改的值。 + +### 访问 Dify + +访问管理员初始化页面以设置管理员账户: + +```bash +# 本地环境 +http://localhost/install + +# 服务器环境 +http://your_server_ip/install +``` + +Dify Web 界面地址: + +```bash +# 本地环境 +http://localhost + +# 服务器环境 +http://your_server_ip +``` + +### 自定义 Dify + +直接编辑您的 `.env` 文件中的环境变量值。然后,使用以下命令重启 Dify: + +``` +docker compose down +docker compose up -d +``` + +完整的带注释环境变量集合可在 docker/.env.example 下找到。 + +### 了解更多 + +如果您有任何问题,请参阅 [常见问题解答](/en/self-hosting/quick-start/faqs)。 + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/docker-compose.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/cn/self-hosting/quick-start/faqs.mdx b/cn/self-hosting/quick-start/faqs.mdx new file mode 100644 index 00000000..7dd0199b --- /dev/null +++ b/cn/self-hosting/quick-start/faqs.mdx @@ -0,0 +1,57 @@ +--- +title: 常见问题 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/quick-start/faqs)。 + + +## 部署方法 + +### 安装旧版本 + +使用 `--branch` 标志来安装特定版本: + +```bash +git clone https://github.com/langgenius/dify.git --branch 0.15.3 +``` + +其余设置与安装最新版本相同。 + +### 使用 ZIP 压缩包安装 + +对于网络受限环境或无法使用 git 的情况: + +```bash +# 下载最新版本 +wget -O dify.zip "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r '.zipball_url')" +unzip dify.zip && rm dify.zip +``` + +或者,在另一台设备上下载 ZIP 文件并手动传输。 + +**升级方法:** +```bash +wget -O dify-latest.zip "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r '.zipball_url')" +unzip dify-latest.zip && rm dify-latest.zip +rsync -a dify-latest/ dify/ +rm -rf dify-latest/ +cd dify/docker +docker compose pull +docker compose up -d +``` + +## 备份程序 + +### 升级前创建备份 + +升级前务必备份以防止数据丢失: + +```bash +cp -r dify "dify.bak.$(date +%Y%m%d%H%M%S)" +``` + +这将创建一个带时间戳的备份,便于轻松恢复。 + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/faqs.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/cn/self-hosting/troubleshooting/common-issues.mdx b/cn/self-hosting/troubleshooting/common-issues.mdx new file mode 100644 index 00000000..d043aff6 --- /dev/null +++ b/cn/self-hosting/troubleshooting/common-issues.mdx @@ -0,0 +1,134 @@ +--- +title: 常见问题 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/troubleshooting/common-issues)。 + +## 身份验证与访问 + +### 重置管理员密码 + +对于 Docker Compose 部署: + +```bash +docker exec -it docker-api-1 flask reset-password +``` + +在提示时输入账户邮箱和新密码。 + +对于源代码部署,在 `api` 目录下运行相同命令。 + +### 登录后出现 401 错误 + +这通常发生在更改域名之后。请更新以下环境变量: + +- `CONSOLE_CORS_ALLOW_ORIGINS` - 控制台 CORS 策略 +- `WEB_API_CORS_ALLOW_ORIGINS` - WebApp CORS 策略 +- `CONSOLE_API_URL` - 控制台 API 的后端 URL +- `CONSOLE_WEB_URL` - 控制台 Web 的前端 URL +- `SERVICE_API_URL` - 服务 API URL +- `APP_API_URL` - WebApp API 后端 URL +- `APP_WEB_URL` - WebApp URL + +更新配置后重启服务。 + +## 配置 + +### 更改默认端口 + +修改 `.env` 配置: + +``` +EXPOSE_NGINX_PORT=80 +EXPOSE_NGINX_SSL_PORT=443 +``` + +如需更改 API 服务端口,请更新 `docker-compose.yaml` 中的 nginx 配置。 + +### 增加文件上传限制 + +在 `.env` 中更新: + +- `UPLOAD_FILE_SIZE_LIMIT` - 最大文件大小 +- `NGINX_CLIENT_MAX_BODY_SIZE` - 必须匹配以避免问题 + +### 工作流复杂度限制 + +在 `web/app/components/workflow/constants.ts` 中调整 `MAX_TREE_DEPTH`(默认值:50)。 + +注意:过大的深度会影响性能。 + +### 节点执行超时 + +在 `.env` 中设置 `TEXT_GENERATION_TIMEOUT_MS` 以控制每个节点的运行时间。 + +## 邮件配置 + +收不到密码重置邮件?请在 `.env` 中配置邮件设置: + +1. 设置邮件参数(SMTP 设置) +2. 重启服务: + +```bash +docker compose down +docker compose up -d +``` + +如果邮件仍未到达,请检查垃圾邮件文件夹。 + +### 在没有邮件服务的情况下邀请成员 + +在没有配置邮件的本地部署中,邀请页面在发送后会显示一个链接。手动复制并转发此链接给用户。 + +## 数据库问题 + +### pg_hba.conf 连接错误 + +如果您看到: +``` +FATAL: no pg_hba.conf entry for host "172.19.0.7", user "postgres", database "dify", no encryption +``` + +允许来自错误中网络段的连接: + +```bash +docker exec -it docker-db-1 sh -c "echo 'host all all 172.19.0.0/16 trust' >> /var/lib/postgresql/data/pgdata/pg_hba.conf" +docker-compose restart +``` + +### 加密密钥文件未找到错误 + +此错误发生在更改部署方法或删除 `api/storage/privkeys` 之后: + +``` +FileNotFoundError: File not found +File "/www/wwwroot/dify/dify/api/libs/rsa.py", line 45, in decrypt +``` + +重置加密密钥对: + +Docker Compose: +```bash +docker exec -it docker-api-1 flask reset-encrypt-key-pair +``` + +源代码(在 `api` 目录下): +```bash +flask reset-encrypt-key-pair +``` + +**警告**:此操作不可逆 - 现有加密数据将丢失。 + +## 工作空间管理 + +### 重命名工作空间 + +直接修改数据库中的 `tenants` 表。 + +### 更改应用程序访问域名 + +在 `docker-compose.yaml` 中更新 `APP_WEB_URL`。 + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/common-issues.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/cn/self-hosting/troubleshooting/docker-issues.mdx b/cn/self-hosting/troubleshooting/docker-issues.mdx new file mode 100644 index 00000000..881a6dae --- /dev/null +++ b/cn/self-hosting/troubleshooting/docker-issues.mdx @@ -0,0 +1,129 @@ +--- +title: Docker 问题 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/troubleshooting/docker-issues)。 + +## 网络与连接 + +### 502 Bad Gateway + +Nginx 正在转发到错误的容器 IP。获取当前容器 IP: + +```bash +docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' +``` + +找到这些行: +``` +/docker-web-1: 172.19.0.5 +/docker-api-1: 172.19.0.7 +``` + +更新 `dify/docker/nginx/conf.d`: +- 将 `http://api:5001` 替换为 `http://172.19.0.7:5001` +- 将 `http://web:3000` 替换为 `http://172.19.0.5:3000` + +重启 nginx 或重新加载配置。注意:IP 在容器重启时会发生变化。 + +### 无法访问 localhost 服务 + +Docker 容器无法通过 `127.0.0.1` 访问主机服务。请使用您机器的本地网络 IP。 + +示例:对于在主机上运行的 OpenLLM,使用 `http://192.168.1.100:port`(您的实际本地 IP)配置 Dify。 + +### 页面一直加载并出现 CORS 错误 + +域名/URL 更改会导致跨源问题。在 `docker-compose.yml` 中更新: + +- `CONSOLE_API_URL` - 控制台 API 的后端 URL +- `CONSOLE_WEB_URL` - 控制台 Web 的前端 URL +- `SERVICE_API_URL` - 服务 API URL +- `APP_API_URL` - WebApp API 后端 URL +- `APP_WEB_URL` - WebApp URL + +## 挂载与卷 + +### Nginx 配置挂载失败 + +错误信息: +``` +Error mounting "/run/desktop/mnt/host/d/Documents/docker/nginx/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": not a directory +``` + +克隆完整项目并从 docker 目录运行: + +```bash +git clone https://github.com/langgenius/dify.git +cd dify/docker +docker compose up -d +``` + +### 端口冲突 + +端口 80 已被使用?可选择: + +1. 停止冲突的服务(通常是 Apache/Nginx): + ```bash + sudo service nginx stop + sudo service apache2 stop + ``` + +2. 或在 `docker-compose.yaml` 中更改端口映射: + ```yaml + ports: + - "8080:80" # 映射到不同端口 + ``` + +## 容器管理 + +### 查看后台 shell 输出 + +列出运行中的 shell: +```bash +docker exec -it docker-api-1 ls /tmp/shells/ +``` + +检查 shell 输出: +```bash +docker exec -it docker-api-1 cat /tmp/shells/[shell-id]/output.log +``` + +### 容器重启问题 + +系统重启后,容器可能无法连接。确保正确的启动顺序: + +```bash +docker compose down +docker compose up -d +``` + +等待所有服务健康后再访问。 + +## SSRF 代理 + +`ssrf_proxy` 容器防止服务器端请求伪造攻击。 + +### 自定义代理规则 + +编辑 `docker/volumes/ssrf_proxy/squid.conf` 添加 ACL 规则: + +``` +# 阻止访问敏感内部 IP +acl restricted_ip dst 192.168.101.19 +acl localnet src 192.168.101.0/24 + +http_access deny restricted_ip +http_access allow localnet +http_access deny all +``` + +更改后重启代理容器。 + +### 为什么需要 SSRF_PROXY? + +防止服务向内网资源发出未授权请求。代理会拦截并过滤来自沙盒服务的所有出站请求。 + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/docker-issues.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template \ No newline at end of file diff --git a/cn/self-hosting/troubleshooting/integrations.mdx b/cn/self-hosting/troubleshooting/integrations.mdx new file mode 100644 index 00000000..0ce20bb1 --- /dev/null +++ b/cn/self-hosting/troubleshooting/integrations.mdx @@ -0,0 +1,100 @@ +--- +title: 第三方集成 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/troubleshooting/integrations)。 + +## Notion 集成 + +Notion OAuth 仅支持 HTTPS,因此本地部署必须使用内部集成。 + +### 配置环境变量 + +在 `.env` 中设置: + +``` +NOTION_INTEGRATION_TYPE=internal +NOTION_INTERNAL_SECRET=your_internal_secret_here +``` + +对于公共集成(仅限 HTTPS): +``` +NOTION_INTEGRATION_TYPE=public +NOTION_CLIENT_SECRET=oauth_client_secret +NOTION_CLIENT_ID=oauth_client_id +``` + +从 [Notion Integrations](https://www.notion.so/my-integrations) 获取凭证。 + +## 文本转语音 (TTS) + +### FFmpeg 未安装错误 + +OpenAI 文本转语音需要 FFmpeg 进行音频流分段。 + +**macOS:** +```bash +brew install ffmpeg +``` + +**Ubuntu:** +```bash +sudo apt-get update +sudo apt-get install ffmpeg +``` + +**CentOS:** +```bash +sudo yum install epel-release +sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm +sudo yum update +sudo yum install ffmpeg ffmpeg-devel +``` + +**Windows:** +1. 从 [FFmpeg 网站](https://ffmpeg.org/download.html) 下载 +2. 解压并移动到 `C:\Program Files\` +3. 将 FFmpeg bin 目录添加到系统 PATH +4. 验证:`ffmpeg -version` + +## 模型标记器 + +### 无法为 'gpt2' 加载标记器 + +错误: +``` +Can't load tokenizer for 'gpt2'. If you were trying to load it from 'https://huggingface.co/models'... +``` + +在环境变量中配置 Hugging Face 镜像或代理。详细信息请参见[环境文档](https://docs.dify.ai/getting-started/install-self-hosted/environments)。 + +## 安全策略 + +### 内容安全策略 (CSP) + +启用 CSP 以减少 XSS 攻击。 + +在 `.env` 中: +``` +CSP_WHITELIST=https://api.example.com,https://cdn.example.com +``` + +添加应用程序使用的所有域名(API、CDN、分析工具等)。 + +更多信息请参见 [MDN CSP 文档](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)。 + +## 应用程序模板 + +### 自定义模板 + +社区版目前不支持。默认模板由 Dify 提供,仅供参考。 + +云版本用户可以: +- 将应用程序添加到工作区 +- 自定义并保存为个人应用程序 + +如需企业自定义模板,请联系:business@dify.ai + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/integrations.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/cn/self-hosting/troubleshooting/storage-and-migration.mdx b/cn/self-hosting/troubleshooting/storage-and-migration.mdx new file mode 100644 index 00000000..80ca2a0d --- /dev/null +++ b/cn/self-hosting/troubleshooting/storage-and-migration.mdx @@ -0,0 +1,157 @@ +--- +title: 存储与迁移 +--- + + ⚠️ 本文档由 AI 自动翻译。如有任何不准确之处,请参考[英文原版](/en/self-hosting/troubleshooting/storage-and-migration)。 + +## 向量数据库迁移 + +### 从 Weaviate 迁移到其他数据库 + +1. **更新配置** + + 源码部署 (`.env`): + ``` + VECTOR_STORE=qdrant + ``` + + Docker Compose (`docker-compose.yaml`): + ```yaml + VECTOR_STORE: qdrant + ``` + +2. **运行迁移** + + ```bash + # 源码 + flask vdb-migrate + + # Docker + docker exec -it docker-api-1 flask vdb-migrate + ``` + +已测试的数据库:Qdrant、Milvus、AnalyticDB + +## 存储迁移 + +### 从本地存储迁移到云存储 + +将文件从本地存储迁移到云服务提供商(例如阿里云 OSS): + +1. **配置云存储** + + `.env` 或 `docker-compose.yaml`: + ``` + STORAGE_TYPE=aliyun-oss + # 添加 OSS 凭据 + ``` + +2. **迁移数据** + + 源码: + ```bash + flask upload-private-key-file-to-cloud-storage + flask upload-local-files-to-cloud-storage + ``` + + Docker: + ```bash + docker exec -it docker-api-1 flask upload-private-key-file-to-cloud-storage + docker exec -it docker-api-1 flask upload-local-files-to-cloud-storage + ``` + +## 数据清理 + +### 删除旧日志 + +1. **获取租户 ID** + ```bash + docker exec -it docker-api-1 bash -c "echo 'from models import Tenant; db.session.query(Tenant.id, Tenant.name).all(); quit()' | flask shell" + ``` + +2. **删除 X 天前的日志** + ```bash + docker exec -it docker-api-1 flask clear-free-plan-tenant-expired-logs \ + --days 30 \ + --batch 100 \ + --tenant_ids 618b5d66-a1f5-4b6b-8d12-f171182a1cb2 + ``` + +3. **移除导出的日志**(可选) + ```bash + docker exec -it docker-api-1 bash -c 'rm -rf ${OPENDAL_FS_ROOT}/free_plan_tenant_expired_logs' + ``` + +### 移除孤立文件 + +**警告**:运行前备份数据库和存储。在维护窗口期间运行。 + +1. **清理数据库记录** + ```bash + docker exec -it docker-api-1 flask clear-orphaned-file-records + # 使用 -f 标志跳过确认 + ``` + +2. **从存储中删除孤立文件** + ```bashd-files-on-storage + # 使用 -f 标志跳过确认 + ``` + +注意:仅适用于 OpenDAL 存储(`STORAGE_TYPE=opendal`)。 + +## 备份与恢复 + +### 升级前创建备份 + +```bash +cp -r dify "dify.bak.$(date +%Y%m%d%H%M%S)" +``` + +### 备份内容 + +对于 Docker Compose 部署: +- 整个 `dify/docker/volumes` 目录 + +对于源码部署: +- 数据库 +- 存储配置 +- 向量数据库数据 +- 环境文件 + +### 数据库维护 + +删除日志后,回收存储空间: + +PostgreSQL: +```sql +VACUUM FULL; +``` + +## 升级流程 + +### 版本升级 + +镜像部署: +```bash +docker compose pull +docker compose up -d +``` + +源码: +```bash +git pull +cd api +flask db upgrade +``` + +### 数据库架构迁移 + +源码更新始终需要: +```bash +cd api +flask db upgrade +``` + +--- + +[编辑此页面](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/storage-and-migration.mdx) | [报告问题](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/docs.json b/docs.json index f7e3aee1..88efd71d 100644 --- a/docs.json +++ b/docs.json @@ -372,7 +372,7 @@ "group": " ", "pages": [ { - "group": "快速开始", + "group": "Getting Started", "pages": [ "cn/documentation/pages/getting-started/introduction", "cn/documentation/pages/getting-started/quick-start", @@ -380,7 +380,7 @@ ] }, { - "group": "节点", + "group": "Nodes", "pages": [ "cn/documentation/pages/nodes/start", "cn/documentation/pages/nodes/llm", @@ -404,7 +404,7 @@ ] }, { - "group": "构建", + "group": "Build", "pages": [ "cn/documentation/pages/build/shortcut-key", "cn/documentation/pages/build/orchestrate-node", @@ -415,7 +415,7 @@ ] }, { - "group": "调试", + "group": "Debug", "pages": [ "cn/documentation/pages/debug/step-run", "cn/documentation/pages/debug/variable-inspect", @@ -424,33 +424,46 @@ ] }, { - "group": "发布", + "group": "Publish", "pages": [ "cn/documentation/pages/publish/README", - "cn/documentation/pages/publish/workflow-webapp", - "cn/documentation/pages/publish/chatflow-webapp", - "cn/documentation/pages/publish/web-app-settings", + { + "group": "Web App", + "icon": "lock", + "pages": [ + "cn/documentation/pages/publish/webapp/workflow-webapp", + "cn/documentation/pages/publish/webapp/chatflow-webapp", + "cn/documentation/pages/publish/webapp/web-app-settings", + "cn/documentation/pages/publish/webapp/web-app-access", + "cn/documentation/pages/publish/webapp/embedding-in-websites" + ] + }, "cn/documentation/pages/publish/publish-mcp", - "cn/documentation/pages/publish/embedding-in-websites", "cn/documentation/pages/publish/developing-with-apis" ] }, { - "group": "监控", + "group": "Monitor", "pages": [ "cn/documentation/pages/monitor/analysis", "cn/documentation/pages/monitor/logs", "cn/documentation/pages/monitor/annotation-reply", - "cn/documentation/pages/monitor/integrate-langsmith", - "cn/documentation/pages/monitor/integrate-langfuse", - "cn/documentation/pages/monitor/integrate-arize", - "cn/documentation/pages/monitor/integrate-opik", - "cn/documentation/pages/monitor/integrate-phoenix", - "cn/documentation/pages/monitor/integrate-weave" + { + "group": "Integrations", + "icon": "grid-2-plus", + "pages": [ + "cn/documentation/pages/monitor/integrations/integrate-langsmith", + "cn/documentation/pages/monitor/integrations/integrate-langfuse", + "cn/documentation/pages/monitor/integrations/integrate-arize", + "cn/documentation/pages/monitor/integrations/integrate-opik", + "cn/documentation/pages/monitor/integrations/integrate-phoenix", + "cn/documentation/pages/monitor/integrations/integrate-weave" + ] + } ] }, { - "group": "知识库", + "group": "Knowledge", "pages": [ "cn/documentation/pages/knowledge/readme", { @@ -471,7 +484,7 @@ ] }, { - "group": "通过知识流水线创建知识库", + "group": "Create from Knowledge Pipeline", "icon": "pipe-section", "pages": [ "cn/documentation/pages/knowledge/knowledge-pipeline/readme", @@ -501,7 +514,7 @@ ] }, { - "group": "工作区", + "group": "Workspace", "pages": [ "cn/documentation/pages/workspace/readme", "cn/documentation/pages/workspace/model-providers", @@ -513,8 +526,9 @@ ] }, { - "group": "教程", + "group": "Tutorials", "pages": [ + "cn/documentation/pages/tutorials/simple-chatbot", "cn/documentation/pages/tutorials/twitter-chatflow", "cn/documentation/pages/tutorials/customer-service-bot", "cn/documentation/pages/tutorials/build-ai-image-generation-app", @@ -525,6 +539,70 @@ } ] }, + { + "dropdown": "自托管", + "icon": "server", + "pages": [ + { + "group": "Quick Start", + "pages": [ + "cn/self-hosting/quick-start/docker-compose", + "cn/self-hosting/quick-start/faqs" + ] + }, + { + "group": "Advanced Deployments", + "pages": [ + "cn/self-hosting/advanced-deployments/local-source-code", + "cn/self-hosting/advanced-deployments/start-the-frontend-docker-container" + ] + }, + { + "group": "Configuration", + "pages": [ + "cn/self-hosting/configuration/environments" + ] + }, + { + "group": "Platform Guides", + "pages": [ + "cn/self-hosting/platform-guides/bt-panel", + "cn/self-hosting/platform-guides/dify-premium" + ] + }, + { + "group": "Troubleshooting", + "pages": [ + "cn/self-hosting/troubleshooting/common-issues", + "cn/self-hosting/troubleshooting/docker-issues", + "cn/self-hosting/troubleshooting/integrations", + "cn/self-hosting/troubleshooting/storage-and-migration" + ] + } + ] + }, + { + "dropdown": "访问 API", + "icon": "code", + "groups": [ + { + "group": "Chatbot 和 Agent", + "openapi": "cn/api-reference/openapi_chat.json" + }, + { + "group": "Chatflow", + "openapi": "cn/api-reference/openapi_chatflow.json" + }, + { + "group": "工作流", + "openapi": "cn/api-reference/openapi_workflow.json" + }, + { + "group": "文本生成", + "openapi": "cn/api-reference/openapi_completion.json" + } + ] + }, { "dropdown": "插件开发", "groups": [ @@ -657,35 +735,6 @@ ] } ] - }, - { - "dropdown": "访问 API", - "groups": [ - { - "group": "Chatbot 和 Agent", - "openapi": "cn/openapi_chat.json" - }, - { - "group": "Chatflow", - "openapi": "cn/openapi_chatflow.json" - }, - { - "group": "工作流", - "openapi": "cn/openapi_workflow.json" - }, - { - "group": "文本生成", - "openapi": "cn/openapi_completion.json" - } - ] - }, - { - "dropdown": "资源", - "pages": [ - "cn/resources/termbase", - "cn/resources/about-dify/dify-brand-guidelines", - "cn/resources/about-dify/dify-brand-usage-terms" - ] } ] }, @@ -854,6 +903,48 @@ } ] }, + { + "dropdown": "セルフホスティング", + "icon": "server", + "pages": [ + { + "group": "Quick Start", + "pages": [ + "jp/self-hosting/quick-start/docker-compose", + "jp/self-hosting/quick-start/faqs" + ] + }, + { + "group": "Advanced Deployments", + "pages": [ + "jp/self-hosting/advanced-deployments/local-source-code", + "jp/self-hosting/advanced-deployments/start-the-frontend-docker-container" + ] + }, + { + "group": "Configuration", + "pages": [ + "jp/self-hosting/configuration/environments" + ] + }, + { + "group": "Platform Guides", + "pages": [ + "jp/self-hosting/platform-guides/bt-panel", + "jp/self-hosting/platform-guides/dify-premium" + ] + }, + { + "group": "Troubleshooting", + "pages": [ + "jp/self-hosting/troubleshooting/common-issues", + "jp/self-hosting/troubleshooting/docker-issues", + "jp/self-hosting/troubleshooting/integrations", + "jp/self-hosting/troubleshooting/storage-and-migration" + ] + } + ] + }, { "dropdown": "プラグイン開発", "groups": [ @@ -992,19 +1083,19 @@ "groups": [ { "group": "ChatbotとAgent", - "openapi": "jp/openapi_chat.json" + "openapi": "jp/api-reference/openapi_chat.json" }, { "group": "チャットフロー", - "openapi": "jp/openapi_chatflow.json" + "openapi": "jp/api-reference/openapi_chatflow.json" }, { "group": "ワークフロー", - "openapi": "jp/openapi_workflow.json" + "openapi": "jp/api-reference/openapi_workflow.json" }, { "group": "テキスト ジェネレーター", - "openapi": "jp/openapi_completion.json" + "openapi": "jp/api-reference/openapi_completion.json" } ] }, @@ -5535,10 +5626,6 @@ "source": "cn/getting-started/dify-premium", "destination": "cn/documentation/pages/getting-started/introduction" }, - { - "source": "cn/getting-started/:slug*", - "destination": "cn/documentation/pages/getting-started/:slug*" - }, { "source": "cn/community/:slug*", "destination": "cn/documentation/pages/getting-started/introduction" diff --git a/jp/self-hosting/advanced-deployments/local-source-code.mdx b/jp/self-hosting/advanced-deployments/local-source-code.mdx new file mode 100644 index 00000000..463e5896 --- /dev/null +++ b/jp/self-hosting/advanced-deployments/local-source-code.mdx @@ -0,0 +1,308 @@ +--- +title: ローカルソースコードからの起動 +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/advanced-deployments/local-source-code)を参照してください。 + +## 前提条件 + +### Docker と Docker Compose のセットアップ + +> Dify をインストールする前に、マシンが以下の最小システム要件を満たしていることを確認してください: +> +> * CPU >= 2 コア +> * RAM >= 4 GiB + +| OS | ソフトウェア | 説明 | +| ------------------ | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| macOS 10.14 以降 | Docker Desktop | Docker 仮想マシン(VM)が最低 2 つの仮想 CPU(vCPU)と 8 GB の初期メモリを使用するように設定してください。そうしないと、インストールが失敗する可能性があります。詳細については、[Mac 用 Docker Desktop インストールガイド](https://docs.docker.com/desktop/mac/install/)を参照してください。 | +| Linux プラットフォーム | Docker 19.03 以降 Docker Compose 1.25.1 以降 | Docker と Docker Compose のインストール方法については、それぞれ[Docker インストールガイド](https://docs.docker.com/engine/install/)と[Docker Compose インストールガイド](https://docs.docker.com/compose/install/)を参照してください。 | +| WSL 2 が有効な Windows | Docker Desktop | Linux コンテナにバインドされるソースコードやその他のデータは、Windows ファイルシステムではなく Linux ファイルシステムに保存することをお勧めします。詳細については、[Windows での WSL 2 バックエンドを使用した Docker Desktop インストールガイド](https://docs.docker.com/desktop/windows/install/#wsl-2-backend)を参照してください。 | + +> OpenAI TTS を使用する必要がある場合は、正常に機能するためにシステムに `FFmpeg` がインストールされている必要があります。詳細については、[リンク](https://docs.dify.ai/getting-started/install-self-hosted/install-faq#id-14.-what-to-do-if-this-error-occurs-in-text-to-speech)を参照してください。 + +### Dify リポジトリのクローン + +git コマンドを実行して [Dify リポジトリ](https://github.com/langgenius/dify) をクローンします。 + +```Bash +git clone https://github.com/langgenius/dify.git +``` + +### Docker Compose でミドルウェアを起動する + +ストレージ用(PostgreSQL / Redis / Weaviate(ローカルで利用できない場合))や拡張機能用(Dify の [sandbox](https://github.com/langgenius/dify-sandbox) や [plugin-daemon](https://github.com/langgenius/dify-plugin-daemon) サービスなど)の一連のミドルウェアが Dify バックエンドサービスで必要です。次のコマンドを実行して Docker Compose でミドルウェアを起動します: + +```Bash +cd docker +cp middleware.env.example middleware.env +docker compose -f docker-compose.middleware.yaml up -d +``` + +*** + +## バックエンドサービスのセットアップ + +バックエンドサービスには以下が含まれます: + +1. API サービス:フロントエンドサービスと API アクセス用の API リクエストを提供 +2. Worker サービス:データセット処理、ワークスペース、クリーンアップなどの非同期タスクを提供 + +### 環境の準備 + +Python 3.12 が必要です。Python 環境をすばやくインストールするには [pyenv](https://github.com/pyenv/pyenv) の使用をお勧めします。 + +追加の Python バージョンをインストールするには、pyenv install を使用します。 + +```Bash +pyenv install 3.12 +``` + +「3.12」Python 環境に切り替えるには、次のコマンドを使用します: + +```Bash +pyenv global 3.12 +``` + +### API サービスの起動 + +1. `api` ディレクトリに移動します: + + ``` + cd api + ``` + +2. 環境変数設定ファイルを準備します + + ``` + cp .env.example .env + ``` + +3. ランダムな秘密鍵を生成し、.env ファイルの SECRET\_KEY の値を置き換えます + + ``` + awk -v key="$(openssl rand -base64 42)" '/^SECRET_KEY=/ {sub(/=.*/, "=" key)} 1' .env > temp_env && mv temp_env .env + ``` + +4. 依存関係のインストール + + 依存関係の管理には [uv](https://docs.astral.sh/uv/getting-started/installation/) を使用します。 + `uv` で必要な依存関係をインストールするには、次のコマンドを実行します: + + ``` + uv sync + ``` + + > macOS の場合:`brew install libmagic` で libmagic をインストールしてください。 + +5. データベースの移行を実行する + + データベースを最新バージョンに移行します: + + ``` + uv run flask db upgrade + ``` + +6. API サービスを起動する + + ``` + uv run flask run --host 0.0.0.0 --port=5001 --debug + ``` + + 期待される出力: + + ``` + * Debug mode: on + INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:5001 + INFO:werkzeug:Press CTRL+C to quit + INFO:werkzeug: * Restarting with stat + WARNING:werkzeug: * Debugger is active! + INFO:werkzeug: * Debugger PIN: 695-801-919 + ``` + +### Worker サービスの起動 + +データセットファイルのインポートやデータセットドキュメントの更新などのキューからの非同期タスクを処理するには、以下の手順に従って Worker サービスを起動します + +* macOS または Linux の場合 + + ``` + uv run celery -A app.celery worker -P gevent -c 1 --loglevel INFO -Q dataset,generation,mail,ops_trace + ``` + + Windows システムで Worker サービスを起動する場合は、代わりに次のコマンドを使用してください: + +* Windows の場合 + + ``` + uv run celery -A app.celery worker -P solo --without-gossip --without-mingle -Q dataset,generation,mail,ops_trace --loglevel INFO + ``` + + 期待される出力: + + ``` + -------------- celery@bwdeMacBook-Pro-2.local v5.4.0 (opalescent) + --- ***** ----- + -- ******* ---- macOS-15.4.1-arm64-arm-64bit 2025-04-28 17:07:14 + - *** --- * --- + - ** ---------- [config] + - ** ---------- .> app: app_factory:0x1439e8590 + - ** ---------- .> transport: redis://:**@localhost:6379/1 + - ** ---------- .> results: postgresql://postgres:**@localhost:5432/dify + - *** --- * --- .> concurrency: 1 (gevent) + -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker) + --- ***** ----- + -------------- [queues] + .> dataset exchange=dataset(direct) key=dataset + .> generation exchange=generation(direct) key=generation + .> mail exchange=mail(direct) key=mail + .> ops_trace exchange=ops_trace(direct) key=ops_trace + + [tasks] + . schedule.clean_embedding_cache_task.clean_embedding_cache_task + . schedule.clean_messages.clean_messages + . schedule.clean_unused_datasets_task.clean_unused_datasets_task + . schedule.create_tidb_serverless_task.create_tidb_serverless_task + . schedule.mail_clean_document_notify_task.mail_clean_document_notify_task + . schedule.update_tidb_serverless_status_task.update_tidb_serverless_status_task + . tasks.add_document_to_index_task.add_document_to_index_task + . tasks.annotation.add_annotation_to_index_task.add_annotation_to_index_task + . tasks.annotation.batch_import_annotations_task.batch_import_annotations_task + . tasks.annotation.delete_annotation_index_task.delete_annotation_index_task + . tasks.annotation.disable_annotation_reply_task.disable_annotation_reply_task + . tasks.annotation.enable_annotation_reply_task.enable_annotation_reply_task + . tasks.annotation.update_annotation_to_index_task.update_annotation_to_index_task + . tasks.batch_clean_document_task.batch_clean_document_task + . tasks.batch_create_segment_to_index_task.batch_create_segment_to_index_task + . tasks.clean_dataset_task.clean_dataset_task + . tasks.clean_document_task.clean_document_task + . tasks.clean_notion_document_task.clean_notion_document_task + . tasks.deal_dataset_vector_index_task.deal_dataset_vector_index_task + . tasks.delete_account_task.delete_account_task + . tasks.delete_segment_from_index_task.delete_segment_from_index_task + . tasks.disable_segment_from_index_task.disable_segment_from_index_task + . tasks.disable_segments_from_index_task.disable_segments_from_index_task + . tasks.document_indexing_sync_task.document_indexing_sync_task + . tasks.document_indexing_task.document_indexing_task + . tasks.document_indexing_update_task.document_indexing_update_task + . tasks.duplicate_document_indexing_task.duplicate_document_indexing_task + . tasks.enable_segments_to_index_task.enable_segments_to_index_task + . tasks.mail_account_deletion_task.send_account_deletion_verification_code + . tasks.mail_account_deletion_task.send_deletion_success_task + . tasks.mail_email_code_login.send_email_code_login_mail_task + . tasks.mail_invite_member_task.send_invite_member_mail_task + . tasks.mail_reset_password_task.send_reset_password_mail_task + . tasks.ops_trace_task.process_trace_tasks + . tasks.recover_document_indexing_task.recover_document_indexing_task + . tasks.remove_app_and_related_data_task.remove_app_and_related_data_task + . tasks.remove_document_from_index_task.remove_document_from_index_task + . tasks.retry_document_indexing_task.retry_document_indexing_task + . tasks.sync_website_document_indexing_task.sync_website_document_indexing_task + + 2025-04-28 17:07:14,681 INFO [connection.py:22] Connected to redis://:**@localhost:6379/1 + 2025-04-28 17:07:14,684 INFO [mingle.py:40] mingle: searching for neighbors + 2025-04-28 17:07:15,704 INFO [mingle.py:49] mingle: all alone + 2025-04-28 17:07:15,733 INFO [worker.py:175] celery@bwdeMacBook-Pro-2.local ready. + 2025-04-28 17:07:15,742 INFO [pidbox.py:111] pidbox: Connected to redis://:**@localhost:6379/1. + ``` + +*** + +## Web サービスのセットアップ + +フロントエンドページ用の Web サービスを起動します。 + +### 環境の準備 + +Web フロントエンドサービスを起動するには、[Node.js v22 (LTS)](http://nodejs.org/) と [PNPM v10](https://pnpm.io/) が必要です。 + +* NodeJS のインストール + + [https://nodejs.org/en/download](https://nodejs.org/en/download) にアクセスし、v18.x 以上のお使いのオペレーティングシステム用のインストールパッケージを選択してください。一般的な使用には LTS バージョンをお勧めします。 + +* PNPM のインストール + + [インストールガイド](https://pnpm.io/installation) に従って PNPM をインストールします。または、以下のコマンドで `npm` を使用して `pnpm` をインストールできます。 + + ``` + npm i -g pnpm + ``` + +### Web サービスの起動 + +1. web ディレクトリに移動します + + ``` + cd web + ``` + +2. 依存関係をインストールします + + ``` + pnpm install --frozen-lockfile + ``` + +3. 環境変数設定ファイルを準備します + + 現在のディレクトリに `.env.local` というファイルを作成し、`.env.example` の内容をコピーします。必要に応じてこれらの環境変数の値を変更します: + + ``` + # For production release, change this to PRODUCTION + NEXT_PUBLIC_DEPLOY_ENV=DEVELOPMENT + # The deployment edition, SELF_HOSTED or CLOUD + NEXT_PUBLIC_EDITION=SELF_HOSTED + # 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/api + NEXT_PUBLIC_API_PREFIX=http://localhost:5001/console/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/api + NEXT_PUBLIC_PUBLIC_API_PREFIX=http://localhost:5001/api + + # SENTRY + NEXT_PUBLIC_SENTRY_DSN= + NEXT_PUBLIC_SENTRY_ORG= + NEXT_PUBLIC_SENTRY_PROJECT= + ``` + +4. Web サービスをビルドします + + ``` + pnpm build + ``` + +5. Web サービスを起動します + + ``` + pnpm start + ``` + + 期待される出力: + + ``` + ▲ Next.js 15 + - Local: http://localhost:3000 + - Network: http://0.0.0.0:3000 + + ✓ Starting... + ✓ Ready in 73ms + ``` + +### Dify にアクセスする + +ブラウザで [http://127.0.0.1:3000](http://127.0.0.1:3000/) にアクセスして、Dify のすべての機能をお楽しみください。 + +乾杯!🍻 + +{/* + Contributing Section + DO NOT edit this section! + It will be automatically generated by the script. + */} + +*** + +[このページを編集する](https://github.com/langgenius/dify-docs/edit/main/ja-jp/getting-started/install-self-hosted/local-source-code.mdx) | [問題を報告する](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) diff --git a/jp/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx b/jp/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx new file mode 100644 index 00000000..f70f887f --- /dev/null +++ b/jp/self-hosting/advanced-deployments/start-the-frontend-docker-container.mdx @@ -0,0 +1,42 @@ +```mdx +--- +title: フロントエンドDockerコンテナを個別に開始する +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/advanced-deployments/start-the-frontend-docker-container)を参照してください。 + +バックエンドを別々に開発する場合、フロントエンドをローカルでビルドして起動せずに、ソースコードからバックエンドサービスのみを開始することができます。この場合、Dockerイメージをプルしてコンテナを実行することで、直接フロントエンドサービスを開始できます。以下は具体的な手順です: + +#### DockerHubからフロントエンドサービス用のDockerイメージをプルする: + +```Bash +docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 langgenius/dify-web:latest +``` + +#### ソースコードからDockerイメージをビルドする + +1. フロントエンドイメージをビルドする + + ``` + cd web && docker build . -t dify-web + ``` + +2. フロントエンドイメージを開始する + + ``` + docker run -it -p 3000:3000 -e CONSOLE_URL=http://127.0.0.1:5001 -e APP_URL=http://127.0.0.1:5001 dify-web + ``` + +3. コンソールドメインとWebアプリドメインが異なる場合は、CONSOLE_URLとAPP_URLを個別に設定できます。 +4. ローカルでアクセスするには、[http://127.0.0.1:3000](http://127.0.0.1:3000/)を訪問してください。 + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[Edit this page](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/start-the-frontend-docker-container.mdx) | [Report an issue](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) +``` \ No newline at end of file diff --git a/jp/self-hosting/platform-guides/bt-panel.mdx b/jp/self-hosting/platform-guides/bt-panel.mdx new file mode 100644 index 00000000..1210c919 --- /dev/null +++ b/jp/self-hosting/platform-guides/bt-panel.mdx @@ -0,0 +1,85 @@ +--- +title: aaPanelでのデプロイ +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/platform-guides/bt-panel)を参照してください。 + + +## 前提条件 + +> Difyをインストールする前に、お使いのマシンが以下の最小システム要件を満たしていることを確認してください: +> +> * CPU >= 2コア +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + +
オペレーティングシステムソフトウェア説明
Linuxプラットフォーム +

aaPanel 7.0.11以降

+
aaPanelのインストール方法については、aaPanelインストールガイドを参照してください。
+## デプロイメント + +1. aaPanelにログインし、メニューバーの`Docker`をクリックします + +2. 初回の場合、`Docker`と`Docker Compose`サービスのインストールが求められますので、「今すぐインストール」をクリックします。既にインストール済みの場合は無視してください。 + +3. インストールが完了したら、`One-Click Install`で`Dify`を見つけて`install`をクリックします + +4. ドメイン名、ポートなどの基本情報を設定してインストールを完了します +> \[!IMPORTANT] +> +> ドメイン名は任意です。ドメイン名を入力した場合、[Website]--> [Proxy Project]で管理できます。ドメイン名を入力した後は[Allow external access]をチェックする必要はありません。そうでない場合は、ポート経由でアクセスするためにチェックが必要です + +5. インストール後、ブラウザでドメイン名またはIP+ポートでアクセスして設定します。 +- Name: アプリケーション名、デフォルト`Dify-characters` +- バージョン選択: デフォルト`latest` +- ドメイン名: ドメイン名で直接アクセスする場合は、ドメイン名を設定してサーバーにドメイン名を解決してください +- 外部アクセス許可: `IP+Port`でアクセスする場合はチェックしてください。ドメイン名を設定した場合はここではチェックしないでください。 +- ポート: デフォルト`8088`、自分で変更できます + +6. 送信後、パネルが自動的にアプリケーションを初期化します。これには約`1-3`分かかります。初期化が完了するとアクセスできます。 + +### Difyへのアクセス + +管理者初期化ページにアクセスして管理者アカウントを設定します: + +```bash +# ドメインを設定した場合 +http://yourdomain/install + +# `IP+Port`でアクセスする場合 +http://your_server_ip:8088/install +``` + +Difyウェブインターフェースアドレス: + +```bash +# ドメインを設定した場合 +http://yourdomain/ + +# `IP+Port`でアクセスする場合 +http://your_server_ip:8088/ +``` + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[このページを編集](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/bt-panel.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/jp/self-hosting/platform-guides/dify-premium.mdx b/jp/self-hosting/platform-guides/dify-premium.mdx new file mode 100644 index 00000000..9dcf6b73 --- /dev/null +++ b/jp/self-hosting/platform-guides/dify-premium.mdx @@ -0,0 +1,139 @@ +--- +title: AWS上のDify Premium +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/platform-guides/dify-premium)を参照してください。 + +Dify Premiumは、カスタムブランディングを可能にし、EC2としてAWS VPCにワンクリックでデプロイできるAWS AMIサービスです。[AWS Marketplace](https://aws.amazon.com/marketplace/pp/prodview-t22mebxzwjhu6)にアクセスして購読してください。以下のようなシナリオで有用です: + +* 中小企業として1つまたは少数のアプリケーションを作成したく、データレジデンシーを重視している。 +* [Dify Cloud](https://cloud.dify.ai)に興味があるが、あなたのユースケースが[プラン](https://dify.ai/pricing)でサポートされているよりも多くのリソースを必要とする。 +* 組織内でDify Enterpriseを採用する前にPOCを実行したい。 + +## セットアップ + +初めてDifyにアクセスする場合は、Admin初期化パスワード(EC2のインスタンスIDに設定)を入力してセットアップ処理を開始します。 + +AMIがデプロイされた後、EC2コンソールで見つけたインスタンスのパブリックIPを通じてDifyにアクセスします(デフォルトではHTTPポート80を使用)。 + +## アップグレード + +EC2インスタンスで、以下のコマンドを実行します: + +``` +git clone https://github.com/langgenius/dify.git /tmp/dify +mv -f /tmp/dify/docker/* /dify/ +rm -rf /tmp/dify +docker-compose down +docker-compose pull +docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d +``` + + + +> このセクションでは、古いCommunity EditionをDify v1.0.0+に移行する方法を説明します。この特定の移行範囲*より後*のバージョンへのDify PremiumまたはCommunity Editionの一般的なアップグレードについては、それぞれのメインアップグレード手順を参照してください。 + +アップグレードプロセスには以下のステップが含まれます: + +1. データのバックアップ +2. プラグインの移行 +3. メインのdifyプロジェクトのアップグレード + +### 1. データのバックアップ + +1.1 `cd`コマンドを実行してDifyプロジェクトディレクトリに移動し、バックアップブランチを作成します。 + +1.2 以下のコマンドを実行してdocker-compose YAMLファイルをバックアップします(オプション)。 + +```bash +cd docker +cp docker-compose.yaml docker-compose.yaml.$(date +%s).bak +``` + +1.3 コマンドを実行してdockerサービスを停止し、Dockerディレクトリでバックアップデータコマンドを実行します。 + +```bash +docker compose down +tar -cvf volumes-$(date +%s).tgz volumes +``` + +### 2. バージョンのアップグレcker Composeによるデプロイをサポートしています。Difyプロジェクトパスに移動し、以下のコマンドを実行してDifyバージョンにアップグレードします: + +```bash +git checkout 1.0.0 # 1.0.0ブランチに切り替え +cd docker +docker compose -f docker-compose.yaml up -d +``` + +### 3. ツールをプラグインに移行 + +> **コマンド実行とパッケージ管理に関する重要な注意(v1.0.0移行用):** +> * **デフォルトコンテナ名:** `docker exec`コマンドの例では`docker-api-1`を使用しています。APIコンテナが異なる名前またはID(`docker ps`を使用して確認可能)を持つ場合は、それに応じてコマンドを調整してください。 +> * **Pythonパッケージマネージャー(`uv` vs. `poetry`):** + * Difyは、パフォーマンス向上のためにバージョン[v1.3.0](https://github.com/langgenius/dify/releases/tag/1.3.0)からPythonパッケージ管理を`poetry`から`uv`に切り替えました。Dify v1.3.0以降の一般的な操作では、標準コマンドは`uv run flask ...`です。 + * **このセクションはDify v1.0.0へのアップグレードに焦点を当てています。** Dify v1.0.0からv1.3.0未満までの期間では、`poetry`がパッケージマネージャーでした。したがって、以下の例の`flask`コマンドは正しく`poetry run ...`を使用しています。コードの例では、コメントで現在の`uv`標準を最初に強調し、次にこの特定のv1.0.0移行範囲に関連する`poetry`コマンドを示します。 + +このステップの目的は、以前にCommunity Editionで使用されていたツールとモデルベンダーを自動的に移行し、新しいプラグイン環境にインストールすることです。 + +1. `docker ps`コマンドを実行してAPIコンテナ名またはIDを確認します。デフォルトは多くの場合`docker-api-1`です。 + +例: + +```bash +docker ps +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +417241cd**** nginx:latest "sh -c 'cp /docker-e…" 3 hours ago Up 3 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp docker-nginx-1 +f84aa773**** langgenius/dify-api:1.0.0 "/bin/bash /entrypoi…" 3 hours ago Up 3 hours 5001/tcp docker-worker-1 +a3cb19c2**** langgenius/dify-api:1.0.0 "/bin/bash /entrypoi…" 3 hours ago Up 3 hours 5001/tcp docker-api-1 +``` + +コマンド`docker exec -it docker-api-1 bash`を実行してコンテナターミナルに入り(コンテナ名が異なる場合はそれを使用)、次に実行します: + +```bash +# Dify v1.3.0+環境では、標準コマンドは'uv run ...'です。 +uv run flask extract-plugins --workers=20 +# +# ゲット移行バージョンがDify v1.0.0からv1.3.0未満の場合は、'poetry'を使用してください: +# poetry run flask extract-plugins --workers=20 +``` + +> v1.0.0移行用のこのガイドに従ってコマンドを実行しようとする際にエラーが発生した場合(例:`uv`または`poetry`が見つからない)、そのバージョンの元の前提条件に従って`poetry`環境がサーバー上で正しく設定されていることを確認してください。`poetry`コマンドの実行後にターミナルで入力を求められた場合は、**「Enter」**を押してスキップしてください。 + +このコマンドは、現在環境で使用中のすべてのモデルとツールを抽出します。workersパラメータは抽出中に使用される並列プロセス数を制御し、必要に応じて調整できます。コマンド実行後、現在のDifyインスタンス内のすべてのワークスペース用のプラグイン情報を含む`plugins.jsonl`ファイルが生成されます。 + +ネットワークがパブリックインターネットにアクセスでき、`https://marketplace.dify.ai`へのアクセスをサポートしていることを確認してください。`docker-api-1`コンテナ内で以下のコマンドを続けて実行します: + +```bash +# Dify v1.3.0+環境では、標準コマンドは'uv run ...'です。 +uv run flask install-plugins --workers=2 +# +# ここで説明するCommunity Edition部分のターゲット移行バージョンがDify v1.0.0からv1.3.0未満の場合は、'poetry'を使用してください: +# poetry run flask install-plugins --workers=2 +``` + +このコマンドは、必要なすべてのプラグインを最新のCommunity Editionにダウンロードしてインストールします。ターミナルに`Install plugins completed.`が表示されると、移行が完了します。 + + + +## カスタマイズ + +セルフホストデプロイと同様に、EC2インスタンス内の`.env`の環境変数を必要に応じて変更できます。その後、以下でDifyを再起動します: + +```bash +docker-compose down +docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d +``` + +## WebAppロゴ & ブランディングのカスタマイズ + +設定の**カスタマイズ**でこの機能を有効にし、**Remove Powered by Dify**を有効にして独自のロゴをアップロードできます。 + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[このページを編集](https://github.com/langgenius/dify/self-hosting/dify-premium.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/jp/self-hosting/quick-start/docker-compose.mdx b/jp/self-hosting/quick-start/docker-compose.mdx new file mode 100644 index 00000000..9328122c --- /dev/null +++ b/jp/self-hosting/quick-start/docker-compose.mdx @@ -0,0 +1,179 @@ +--- +title: Docker Compose +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/quick-start/docker-compose)を参照してください。 + + +## 前提条件 + +> Difyをインストールする前に、お使いのマシンが以下の最小システム要件を満たしていることを確認してください: +> +> * CPU >= 2コア +> * RAM >= 4 GiB + + + + + + + + + + + + + + + + + + + + + + + + + + +
オペレーティングシステムソフトウェア説明
macOS 10.14以降Docker DesktopDocker仮想マシン(VM)が最低2つの仮想CPU(vCPU)と8GBの初期メモリを使用するよう設定してください。そうしないと、インストールが失敗する可能性があります。詳細については、Mac用Docker Desktopインストールガイドを参照してください。
Linuxプラットフォーム +

Docker 19.03以降

+

Docker Compose 1.28以降

+
DockerとDocker Composeのインストール方法の詳細については、DockerインストールガイドおよびDocker Composeインストールガイドをそれぞれ参照してください。
WSL 2が有効なWindowsDocker DesktopLinuxコンテナにバインドされるソースコードや他のデータは、Windowsファイルシステムではなく、Linuxファイルシステムに保存することを推奨します。詳細については、WindowsでWSL 2バックエンドを使用するDocker Desktopインストールガイドを参照してください。
+ +### Difyのクローン + +Difyのソースコードをローカルマシンにクローンします: + +```bash +git clone --branch "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r .tag_name)" https://github.com/langgenius/dify.git +``` + +### Difyの起動 + +1. Difyソースコード内のDockerディレクトリに移動します + + ```bash + cd dify/docker + ``` +2. 環cp .env.example .env + ``` +3. Dockerコンテナを起動します + + システムのDocker Composeバージョンに基づいて、適切なコマンドを選択してコンテナを起動してください。バージョンを確認するには`$ docker compose version`コマンドを使用し、詳細については[Dockerドキュメント](https://docs.docker.com/compose/install/)を参照してください: + + * Docker Compose V2を使用している場合は、以下のコマンドを使用します: + + ```bash + docker compose up -d + ``` + + * Docker Compose V1を使用している場合は、以下のコマンドを使用します: + + ```bash + docker-compose up -d + ``` + +コマンドを実行すると、すべてのコンテナのステータスとポートマッピングを示す以下のような出力が表示されるはずです: + +```bash +[+] Running 11/11 + ✔ Network docker_ssrf_proxy_network Created 0.1s + ✔ Network docker_default Created 0.0s + ✔ Container docker-redis-1 Started 2.4s + ✔ Container docker-ssrf_proxy-1 Started 2.8s + ✔ Container docker-sandbox-1 Started 2.7s + ✔ Container docker-web-1 Started 2.7s + ✔ Container docker-weaviate-1 Started 2.4s + ✔ Container docker-db-1 Started 2.7s + ✔ Container docker-api-1 Started 6.5s + ✔ Container docker-worker-1 Started 6.4s + ✔ Container docker-nginx-1 Started 7.1s +``` + +最後に、すべてのコンテナが正常に動作しているかを確認します: + +```bash +docker compose ps +``` + +これには3つのコアサービス:`api / worker / web`と、6つの依存コンポーネント:`weaviate / db / redis / nginx / ssrf_proxy / sandbox`が含まれます。 + +```bash +NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS +docker-api-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" api About a minute ago Up About a minute 5001/tcp +docker-db-1 postgres:15-alpine "docker-entrypoint.s…" db About a minute ago Up About a minute (healthy) 5432/tcp +docker-nginx-1 nginx:latest "sh -c 'cp /docker-e…" nginx About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp +docker-redis-1 redis:6-alpine "docker-entrypoint.s…" redis About a minute ago Up About a minute (healthy) 6379/tcp +docker-sandbox-1 langgenius/dify-sandbox:0.2.1 "/main" sandbox About a minute ago Up About a minute +docker-ssrf_proxy-1 ubuntu/squid:latest "sh -c 'cp /docker-e…" ssrf_proxy About a minute ago Up About a minute 3128/tcp +docker-weaviate-1 semitechnologies/weaviate:1.19.0 "/bin/weaviate --hos…" weaviate About a minute ago Up About a minute +docker-web-1 langgenius/dify-web:0.6.13 "/bin/sh ./entrypoin…" web About a minute ago Up About a minute 3000/tcp +docker-worker-1 langgenius/dify-api:0.6.13 "/bin/bash /entrypoi…" worker About a minute ago Up About a minute 5001/tcp +``` + +これらの手順により、Difyを正常にインストールできるはずです。 + +### Difyのアップグレード + +difyソースコードのdockerディレクトリに移動し、以下のコマンドを実行します: + +```bash +cd dify/docker +docker compose down +git pull origin main +docker compose pull +docker compose up -d +``` + +#### 環境変数設定の同期(重要) + +* `.env.example`ファイルが更新されている場合は、必ずローカルの`.env`実際の環境に合わせて`.env`ファイルの設定項目を確認・変更してください。`.env.example`から新しい変数を`.env`ファイルに追加し、変更された値を更新する必要がある場合があります。 + +### Difyへのアクセス + +管理者初期化ページにアクセスして、管理者アカウントを設定します: + +```bash +# ローカル環境 +http://localhost/install + +# サーバー環境 +http://your_server_ip/install +``` + +Difyウェブインターフェースのアドレス: + +```bash +# ローカル環境 +http://localhost + +# サーバー環境 +http://your_server_ip +``` + +### Difyのカスタマイズ + +`.env`ファイルの環境変数値を直接編集します。その後、以下のコマンドでDifyを再起動します: + +``` +docker compose down +docker compose up -d +``` + +完全な注釈付き環境変数セットは docker/.env.example で見つけることができます。 + +### 詳細情報 + +ご質問がある場合は、[FAQ](/en/self-hosting/quick-start/faqs)を参照してください。 + +{/* +Contributing Section +DO NOT edit this section! +It will be automatically generated by the script. +*/} + +--- + +[このページを編集](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/docker-compose.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/jp/self-hosting/quick-start/faqs.mdx b/jp/self-hosting/quick-start/faqs.mdx new file mode 100644 index 00000000..02dd72f8 --- /dev/null +++ b/jp/self-hosting/quick-start/faqs.mdx @@ -0,0 +1,56 @@ +--- +title: よくある質問 +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/quick-start/faqs)を参照してください。 + +## デプロイ方法 + +### 旧バージョンのインストール + +`--branch` フラグを使用して特定のバージョンをインストールします: + +```bash +git clone https://github.com/langgenius/dify.git --branch 0.15.3 +``` + +残りのセットアップは最新版のインストールと同じです。 + +### ZIP アーカイブを使用したインストール + +ネットワーク制限がある環境やgitが利用できない場合: + +```bash +# 最新リリースをダウンロード +wget -O dify.zip "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r '.zipball_url')" +unzip dify.zip && rm dify.zip +``` + +または、別のデバイスでZIPをダウンロードして手動で転送することもできます。 + +**アップグレードするには:** +```bash +wget -O dify-latest.zip "$(curl -s https://api.github.com/repos/langgenius/dify/releases/latest | jq -r '.zipball_url')" +unzip dify-latest.zip && rm dify-latest.zip +rsync -a dify-latest/ dify/ +rm -rf dify-latest/ +cd dify/docker +docker compose pull +docker compose up -d +``` + +## バックアップ手順 + +### アップグレード前のバックアップ作成 + +データ損失を防ぐため、アップグレード前は必ずバックアップを行ってください: + +```bash +cp -r dify "dify.bak.$(date +%Y%m%d%H%M%S)" +``` + +これにより、復元しやすいタイムスタンプ付きのバックアップが作成されます。 + +--- + +[このページを編集](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/dify-community/faqs.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/jp/self-hosting/troubleshooting/common-issues.mdx b/jp/self-hosting/troubleshooting/common-issues.mdx new file mode 100644 index 00000000..40fa5788 --- /dev/null +++ b/jp/self-hosting/troubleshooting/common-issues.mdx @@ -0,0 +1,131 @@ +--- +title: よくある問題 +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/troubleshooting/common-issues)を参照してください。 + +## 認証とアクセス + +### 管理者パスワードのリセット + +Docker Composeデプロイメントの場合: + +```bash +docker exec -it docker-api-1 flask reset-password +``` + +プロンプトが表示されたら、アカウントのメールアドレスと新しいパスワードを入力してください。 + +ソースコードデプロイメントの場合は、`api`ディレクトリから同じコマンドを実行してください。 + +### ログイン後の401エラー + +これは通常、ドメインを変更した後に発生します。以下の環境変数を更新してください: + +- `CONSOLE_CORS_ALLOW_ORIGINS` - コンソールCORSポリシー +- `WEB_API_CORS_ALLOW_ORIGINS` - WebアプリCORSポリシー +- `CONSOLE_API_URL` - コンソールAPIのバックエンドURL +- `CONSOLE_WEB_URL` - コンソールWebのフロントエンドURL +- `SERVICE_API_URL` - サービスAPI URL +- `APP_API_URL` - WebアプリAPIバックエンドURL +- `APP_WEB_URL` - WebアプリURL + +設定を更新した後、再起動してください。 + +## 設定 + +### デフォルトポートの変更 + +`.env`設定を変更してください: + +``` +EXPOSE_NGINX_PORT=80 +EXPOSE_NGINX_SSL_PORT=443 +``` + +APIサービスポートを変更する場合は、`docker-compose.yaml`のnginx設定を更新してください。 + +### ファイルアップロード制限の増加 + +`.env`で以下を更新してください: + +- `UPLOAD_FILE_SIZE_LIMIT` - 最大ファイルサイズ +- `NGINX_CLIENT_MAX_BODY_SIZE` - 問題を避けるために一致させる必要があります + +### ワークフローの複雑さ制限 + +`web/app/components/workflow/constants.ts`の`MAX_TREE_DEPTH`を調整してください(デフォルト:50)。 + +注意:過度な深度はパフォーマンスに影響します。 + +### ノード実行タイムアウト + +ノードごとの実行時間を制御するために、`.env`で`TEXT_GENERATION_TIMEOUT_MS`を設定してください。 + +## メール設定 + +パスワードリセットメールが届きませんか?`.env`でメール設定を構成してください: + +1. メールパラメータを設定(SMTP設定) +2. サービスを再起動: + +```bash +docker compose down +docker compose up -d +``` + +メールがまだ届かない場合は、迷惑メールフォルダを確認してください。 + +### メールサービスなしでメンバーを招待 + +メールが設定されていないローカルデプロイメントでは、招待ページは送信後にリンクを表示します。このリンクをコピーして手動でユーザーに転送してください。 + +## データベースの問題 + +### pg_hba.confでの接続エラー + +以下のエラーが表示される場合: +``` +FATAL: no pg_hba.conf entry for host "172.19.0.7", user "postgres", database "dify", no encryption +``` + +エラーのネットワークセグメントit docker-db-1 sh -c "echo 'host all all 172.19.0.0/16 trust' >> /var/lib/postgresql/data/pgdata/pg_hba.conf" +docker-compose restart +``` + +### 暗号化キーのファイルが見つからないエラー + +このエラーは、デプロイメント方法を変更した後、または`api/storage/privkeys`を削除した後に発生します: + +``` +FileNotFoundError: File not found +File "/www/wwwroot/dify/dify/api/libs/rsa.py", line 45, in decrypt +``` + +暗号化キーペアをリセットしてください: + +Docker Compose: +```bash +docker exec -it docker-api-1 flask reset-encrypt-key-pair +``` + +ソースコード(`api`ディレクトリから): +```bash +flask reset-encrypt-key-pair +``` + +**警告**:これは元に戻せません - 既存の暗号化データは失われます。 + +## ワークスペース管理 + +### ワークスペース名の変更 + +データベース内の`tenants`テーブルを直接変更してください。 + +### アプリケーションアクセスドメインの変更 + +`docker-compose.yaml`で`APP_WEB_URL`を更新してください。 + +--- + +[このページを編集](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/common-issues.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/jp/self-hosting/troubleshooting/docker-issues.mdx b/jp/self-hosting/troubleshooting/docker-issues.mdx new file mode 100644 index 00000000..81c39bd8 --- /dev/null +++ b/jp/self-hosting/troubleshooting/docker-issues.mdx @@ -0,0 +1,128 @@ +--- +title: Dockerの問題 +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/troubleshooting/docker-issues)を参照してください。 + +## ネットワークと接続 + +### 502 Bad Gateway + +Nginxが間違ったコンテナIPに転送しています。現在のコンテナIPを取得してください: + +```bash +docker ps -q | xargs -n 1 docker inspect --format '{{ .Name }}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' +``` + +以下の行を見つけてください: +``` +/docker-web-1: 172.19.0.5 +/docker-api-1: 172.19.0.7 +``` + +`dify/docker/nginx/conf.d`を更新してください: +- `http://api:5001`を`http://172.19.0.7:5001`に置き換える +- `http://web:3000`を`http://172.19.0.5:3000`に置き換える + +nginxを再起動するか、設定を再読み込みしてください。注意:IPはコンテナ再起動時に変更されます。 + +### localhostサービスにアクセスできない + +Dockerコンテナは`127.0.0.1`経由でホストサービスにアクセスできません。代わりにマシンのローカルネットワークIPを使用してください。 + +例:ホストで動作しているOpenLLMの場合、Difyを`http://192.168.1.100:port`(実際のローカルIP)で設定してください。 + +### ページが永続的に読み込み中でCORSエラーが発生 + +ドメイン/URLの変更がクロスオリジンの問題を引き起こします。`docker-compose.yml`で更新してください: + +- `CONSOLE_API_URL` - コンソールAPIのバックエンドURL +- `CONSOLE_WEB_URL` - コンソールWebのフロントエンドURL +- `SERVICE_API_URL` - サービスAPIのURL +- `APP_API_URL` - WebAppのAPIバックエンドURL +- `APP_WEB_URL` - WebAppのURL + +## マウントとボリューム + +### Nginx設定のマウント失敗 + +エラー: +``` +Error mounting "/run/desktop/mnt/host/d/Documents/docker/nginx/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": not a directory +``` + +完全なプロジェクトをクローンしてdockerディレクトリから実行してください: + +```bash +git clone https://github.com/langgenius/dify.git +cd dify/docker +docker compose up -d +``` + +### ポート競合 + +ポート80が既に使用中ですか?以下のいずれかを選択してください: + +1. 競合するサービス(通常Apache/Nginx)を停止する: + ```bash + sudo service nginx stop + sudo service apache2 stop + ``` + +2. または`docker-compose.yaml`でポートマッピングを変更する: + ```yaml + ports: + - "8080:80" # 異なるポートにマッピング + ``` + +## コンテナ管理 + +### バックグラウンドシェルの出力を表示 + +実行中のシェルをリスト表示: +```bash +docker exec -it docker-api-1 ls /tmp/shells/ +``` + +シェル出力を確認: +```bash +docker exec -it docker-api-1 cat /tmp/shells/[shell-id]/output.log +``` + +### コンテナ再起動の問題 + +システム再起動後、コンテナの接続が失敗する場合があります。適切な起動順序を確保してください: + +```bash +docker compose down +docker compose up -d +``` + +アクセスする前に、すべてのサービスが正常になるまで待機してください。 + +## SSRFプロキシ + +`ssrf_proxy`コンテナはServer-Side Request Forgery攻撃を防止します。 + +### プロキシルールのカスタマイズ + +`docker/volumes/ssrf_proxy/squid.conf`を編集してACLルールを追加してください: + +``` +# 機密な内部IPへのアクセスをブロック +acl restricted_ip dst 192.168.101.19 +acl localnet src 192.168.101.0/24 + +http_access deny restrictenet +http_access deny all +``` + +変更後はプロキシコンテナを再起動してください。 + +### なぜSSRF_PROXYが必要なのか? + +サービスが内部ネットワークリソースに対して不正なリクエストを行うことを防ぎます。プロキシはサンドボックス化されたサービスからのすべてのアウトバウンドリクエストを傍受してフィルタリングします。 + +--- + +[このページを編集](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/docker-issues.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/jp/self-hosting/troubleshooting/integrations.mdx b/jp/self-hosting/troubleshooting/integrations.mdx new file mode 100644 index 00000000..161d8996 --- /dev/null +++ b/jp/self-hosting/troubleshooting/integrations.mdx @@ -0,0 +1,100 @@ +--- +title: サードパーティ統合 +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/troubleshooting/integrations)を参照してください。 + +## Notion統合 + +Notion OAuthはHTTPSのみをサポートしているため、ローカルデプロイメントでは内部統合を使用する必要があります。 + +### 環境変数の設定 + +`.env`に設定: + +``` +NOTION_INTEGRATION_TYPE=internal +NOTION_INTERNAL_SECRET=your_internal_secret_here +``` + +パブリック統合の場合(HTTPSのみ): +``` +NOTION_INTEGRATION_TYPE=public +NOTION_CLIENT_SECRET=oauth_client_secret +NOTION_CLIENT_ID=oauth_client_id +``` + +認証情報は[Notion Integrations](https://www.notion.so/my-integrations)から取得してください。 + +## テキスト音声変換(TTS) + +### FFmpegが未インストールのエラー + +OpenAI TTSは音声ストリームのセグメンテーションにFFmpegが必要です。 + +**macOS:** +```bash +brew install ffmpeg +``` + +**Ubuntu:** +```bash +sudo apt-get update +sudo apt-get install ffmpeg +``` + +**CentOS:** +```bash +sudo yum install epel-release +sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm +sudo yum update +sudo yum install ffmpeg ffmpeg-devel +``` + +**Windows:** +1. [FFmpeg website](https://ffmpeg.org/download.html)からダウンロード +2. 展開して`C:\Program Files\`に移動 +3. FFmpegのbinディレクトリをシステムPATHに追加 +4. 確認:`ffmpeg -version` + +## モデルトークナイザー + +### 'gpt2'のトークナイザーを読み込めない + +エラー: +``` +Can't load tokenizer for 'gpt2'. If you were trying to load it from 'https://huggingface.co/models'... +``` + +環境変数でHugging Faceミラーまたはプロキシを設定してください。詳細については[環境ドキュメント](https://docs.dify.ai/getting-started/install-self-hosted/environments)をご覧ください。 + +## セキュリティポリシー + +### Content Security Policy(CSP) + +XSS攻撃を軽減するためにCSPを有効にします。 + +`.env`内: +``` +CSP_WHITELIST=https://api.example.com,https://cdn.example.com +``` + +アプリケーションで使用するすべてのドメイン(API、CDN、アナリティクスなど)を追加してください。 + +詳細については[MDN CSPドキュメント](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)をご覧ください。 + +## アプリケーションテンプレート + +### カスタムテンプレート + +現在、コミュニティエディションではサポートされていません。デフォルトテンプレートはDifyによって参考用に提供されています。 + +クラウドバージョンのユーザーは以下が可能です: +- ワークスペースにアプリケーションを追加 +- カスタマイズして個人アプリケーションとして保存 + +エンタープライズのカスタムテンプレートについては、以下にお問い合わせください:business@dify.ai + +--- + +[このページを編集](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/integrations.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/jp/self-hosting/troubleshooting/storage-and-migration.mdx b/jp/self-hosting/troubleshooting/storage-and-migration.mdx new file mode 100644 index 00000000..69f70481 --- /dev/null +++ b/jp/self-hosting/troubleshooting/storage-and-migration.mdx @@ -0,0 +1,156 @@ +--- +title: ストレージとマイグレーション +--- + + ⚠️ このドキュメントはAIによって自動翻訳されています。不正確な部分がある場合は、[英語版](/en/self-hosting/troubleshooting/storage-and-migration)を参照してください。 + +## ベクトルデータベースマイグレーション + +### Weaviateから他のベクトルデータベースへのマイグレーション + +1. **設定の更新** + + ソースコードデプロイ(`.env`): + ``` + VECTOR_STORE=qdrant + ``` + + Docker Compose(`docker-compose.yaml`): + ```yaml + VECTOR_STORE: qdrant + ``` + +2. **マイグレーションの実行** + + ```bash + # ソースコード + flask vdb-migrate + + # Docker + docker exec -it docker-api-1 flask vdb-migrate + ``` + +テスト済みベクトルデータベース:Qdrant、Milvus、AnalyticDB + +## ストレージマイグレーション + +### ローカルストレージからクラウドストレージへの移行 + +ローカルストレージからクラウドプロバイダー(例:Alibaba Cloud OSS)へファイルをマイグレーション: + +1. **クラウドストレージの設定** + + `.env`または`docker-compose.yaml`: + ``` + STORAGE_TYPE=aliyun-oss + # OSS認証情報を追加 + ``` + +2. **データのマイグレーション** + + ソースコード: + ```bash + flask upload-private-key-file-to-cloud-storage + flask upload-local-files-to-cloud-storage + ``` + + Docker: + ```bash + docker exec -it docker-api-1 flask upload-private-key-file-to-cloud-storage + docker exec -it docker-api-1 flask upload-local-files-to-cloud-storage + ``` + +## データクリーンアップ + +### 古いログの削除 + +1. **テナントIDの取得** + ```bash + docker exec -it docker-api-1 bash -c "echo 'from models import Tenant; db.session.query(Tenant.id, Tenant.name).all(); quit()' | flask shell" + ``` + +2. **X日以上古いログの削除** + ```bash + docker exec -it docker-api-1 flask clear-free-plan-tenant-expired-logs \ + --days 30 \ + --batch 100 \ + --tenant_ids 618b5d66-a1f5-4b6b-8d12-f171182a1cb2 + ``` + +3. **エクスポートされたログの削除**(オプション) + ```bash + docker exec -it docker-api-1 bash -c 'rm -rf ${OPENDAL_FS_ROOT}/free_plan_tenant_expired_logs' + ``` + +### 孤立ファイルの削除 + +**警告**:実行前にデータベースとストレージをバックアップしてください。メンテナンス時間中に実行してください。 + +1. **データベースレコードのクリーン** + ```bash + docker exec -it docker-api-1 flask clear-orphaned-file-records + # 確認をスキップするには-fフラグを使用 + ``` + +2. **ストレージから孤立ファイルを削除** + ```bash + docker exec -it docker-api-1 flask remove-orphaned-files-on-storage + # 確認をスキップするには-fフラグを使用 + ``` + +注意:OpenDALストレージ(`STORAGE_TYPE=opendal`)でのみ動作します。 + +## バックアップとリカバリ + +### アップグレード前のバックアップ作成 + +```bash +cp -r dify "dify.bak.$(date +%Y%m%d%H%M%S)" +``` + +### バントの場合: +- `dify/docker/volumes`ディレクトリ全体 + +ソースデプロイメントの場合: +- データベース +- ストレージ設定 +- ベクトルデータベースデータ +- 環境ファイル + +### データベースメンテナンス + +ログ削除後、ストレージを回収: + +PostgreSQL: +```sql +VACUUM FULL; +``` + +## アップグレードプロセス + +### バージョンアップグレード + +イメージデプロイメント: +```bash +docker compose pull +docker compose up -d +``` + +ソースコード: +```bash +git pull +cd api +flask db upgrade +``` + +### データベーススキーママイグレーション + +ソースコード更新時は常に必須: +```bash +cd api +flask db upgrade +``` + +--- + +[このページを編集](https://github.com/langgenius/dify-docs/edit/main/en/self-hosting/troubleshooting/storage-and-migration.mdx) | [問題を報告](https://github.com/langgenius/dify-docs/issues/new?template=docs.yml) \ No newline at end of file diff --git a/versions/3-0-x/jp/user-guide/workflow/debug-and-preview/preview-and-run.mdx b/versions/3-0-x/jp/user-guide/workflow/debug-and-preview/preview-and-run.mdx index 20d218c8..b80bd421 100644 --- a/versions/3-0-x/jp/user-guide/workflow/debug-and-preview/preview-and-run.mdx +++ b/versions/3-0-x/jp/user-guide/workflow/debug-and-preview/preview-and-run.mdx @@ -18,7 +18,7 @@ Difyは完全なデバッグツールを提供し、問題の迅速な特定、 ノードの右上にあるデバッグボタンをクリックし、テストデータを入力して出力結果を確認します。デバッグの過程では、シンプルなテストデータから始めて、徐々にデータの複雑さを増やし、さまざまな入力状況でノードが正常に動作することを確認することをお勧めします。 -単一ノードのデバッグ方法の詳細については、[ノードのデバッグ](/ja-jp/guides/workflow/debug-and-preview/step-run.mdx)を参照してください。 +単一ノードのデバッグ方法の詳細については、[ノードのデバッグ](/ja-jp/guides/workflow/debug-and-preview/step-run)を参照してください。 ![](https://assets-docs.dify.ai/2025/06/44decb6644b140e46ed2e1e9246f48f7.png)