本地私有化部署Dify步骤

Dify部署

一、前置条件

  1. 服务器配置

    • 生产环境:4 核 CPU/8GB 内存 / 100GB 硬盘(推荐 SSD),Linux 系统(如 Ubuntu 22.04)。
    • 开发环境:2 核 CPU/4GB 内存,支持 Docker 的操作系统(Windows 需启用 WSL)。
  2. 软件依赖

    • Docker 20.10.5+ 及 Docker Compose 2.0.0+(K8s 部署需额外安装 kubectl 和 helm)。
    • Python 3.12+(若从源码编译)、Node.js 18.x(前端构建)。

二、部署步骤(以 Docker Compose 为例)

1. 获取部署文件

这里我从github项目的releases里下载了源码包,为了防止直接拉取获取不完整导致错误。

2. 配置docker镜像源

我使用的: docker.1ms.run/ 可自行配置或使用给的脚本一键配置

3. 配置.env文件

直接复制 docker 目录下的 .env.example.env

bash 复制代码
cp .env.example .env

修改.env

必要的修改一般只有common variables下面的所有留空url

需要填入自己的ip以及端口号

API端口号通常是5001 web端口号则是3000

以及注意最后的INTERNAL_FILES_URL稍有不同

bash 复制代码
# ------------------------------
# Common Variables
# ------------------------------

# The backend URL of the console API,
# used to concatenate the authorization callback.
# If empty, it is the same domain.
# Example: https://api.console.dify.ai
CONSOLE_API_URL= http://192.168.101.116:5001

# The front-end URL of the console web,
# used to concatenate some front-end addresses and for CORS configuration use.
# If empty, it is the same domain.
# Example: https://console.dify.ai
CONSOLE_WEB_URL= http://192.168.101.116:3000

# Service API Url,
# used to display Service API Base Url to the front-end.
# If empty, it is the same domain.
# Example: https://api.dify.ai
SERVICE_API_URL= http://192.168.101.116:5001

# WebApp API backend Url,
# used to declare the back-end URL for the front-end API.
# If empty, it is the same domain.
# Example: https://api.app.dify.ai
APP_API_URL= http://192.168.101.116:5001

# WebApp Url,
# used to display WebAPP API Base Url to the front-end.
# If empty, it is the same domain.
# Example: https://app.dify.ai
APP_WEB_URL= http://192.168.101.116:3000

# File preview or download Url prefix.
# used to display File preview or download Url to the front-end or as Multi-model inputs;
# Url is signed and has expiration time.
# Setting FILES_URL is required for file processing plugins.
#   - For https://example.com, use FILES_URL=https://example.com
#   - For http://example.com, use FILES_URL=http://example.com
#   Recommendation: use a dedicated domain (e.g., https://upload.example.com).
#   Alternatively, use http://<your-ip>:5001 or http://api:5001,
#   ensuring port 5001 is externally accessible (see docker-compose.yaml).
FILES_URL=http://192.168.101.116:5001

# INTERNAL_FILES_URL is used for plugin daemon communication within Docker network.
# Set this to the internal Docker service URL for proper plugin file access.
# Example: INTERNAL_FILES_URL=http://api:5001
INTERNAL_FILES_URL=http://api:5001
4. docker拉取环境文件

配置好.env文件后通常可以直接开始docker拉取下载环境后直接打开Dify网页,若拉取后无法打开Dify网页,照第五步排查端口问题并做修改

docker-compose.yaml 所在目录(通常是 dify/docker)执行:

bash 复制代码
# 拉取所有服务依赖的镜像(根据 docker-compose.yaml 配置)
docker compose pull
# 拉取完成后台启动所有服务 
docker compose up -d

成功拉起服务后,打开浏览器输入ip地址即可。

5. 若第四步启动失败

我遇到的问题是网页一直加载,登录界面不出现 此时:

bash 复制代码
#检查每个映射端口是否有误
docker compose ps
#若要操作docker配置文件先暂停docker服务
docker compose down

最终我的问题排查是web和api的映射端口有误导致无法正常启动,解决办法: 修改docker-compose.yaml文件配置

bash 复制代码
- web:下增加ports 映射 "3000:3000"
- api:下 "5001:5001"

保险起见先移除所有已下载镜像卷,修改docker-compose.yaml后重新拉取启动,问题解决。

相关推荐
永远都不秃头的程序员(互关)7 小时前
基于CANN的ops-signal仓库实现AIGC音频生成中的动态窗函数融合优化——从STFT预处理到端到端低延迟合成
aigc·音视频
是枚小菜鸡儿吖7 小时前
从 0 到 1 生成自定义算子:CANN + AIGC 的自动化工作流
运维·自动化·aigc
种时光的人8 小时前
CANN生态场景化部署:cann-deployer实现AIGC大模型一键落地
aigc
多恩Stone8 小时前
【3D AICG 系列-6】OmniPart 训练流程梳理
人工智能·pytorch·算法·3d·aigc
ujainu8 小时前
CANN仓库中的AIGC能效-性能协同优化:昇腾AI软件栈如何实现“既要又要还要”的工程奇迹
人工智能·aigc
敲键盘的生活8 小时前
MoneyPrinter重构之一:用nicegui调用大模型生成视频文案
python·重构·aigc·ai编程·ai写作
那个村的李富贵14 小时前
光影魔术师:CANN加速实时图像风格迁移,让每张照片秒变大师画作
人工智能·aigc·cann
墨风如雪15 小时前
16个AI两周手搓编译器:Claude Opus 4.6 正在改写代码规则
aigc
心疼你的一切17 小时前
昇腾CANN实战落地:从智慧城市到AIGC,解锁五大行业AI应用的算力密码
数据仓库·人工智能·深度学习·aigc·智慧城市·cann
种时光的人17 小时前
CANN仓库核心解读:catlass夯实AIGC大模型矩阵计算的算力基石
线性代数·矩阵·aigc