环境准备

dify下载

wget -O dify-1.13.2.tar.gz https://github.com/langgenius/dify/archive/refs/tags/1.13.2.tar.gz

镜像管理

镜像下载

基础镜像清单, 核心组件大概10个镜像

# --- Dify 核心业务镜像 ---
langgenius/dify-api:1.13.2
langgenius/dify-web:1.13.2
langgenius/dify-sandbox:0.2.12

# --- 基础中间件 (建议使用 alpine 版本以减小体积) ---
postgres:15-alpine
redis:6-alpine
nginx:latest
ubuntu/squid:latest

# --- 默认向量数据库 (Dify 内置集成度最高) ---
semitechnologies/weaviate:1.27.0

# --- 初始化工具 ---
busybox:latest
# --- 插件守护进程 (Plugin Daemon) ---
langgenius/dify-plugin-daemon:0.5.4-local

镜像导入

将镜像load到部署节点

ls *.tar | xargs -I {} docker load -i {} 

Dify部署

tar -zxf dify-1.13.2.tar.gz
mkdir -p /data/dify
cp dify-1.13.2/docker/* /data/dify/
cp dify-1.13.2/docker/.env.example /data/dify/
cd /data/dify
cp .env.example .env

配置变量文件

配置.env变量文件

# 前端访问配置
EXPOSE_NGINX_PORT=8081
EXPOSE_NGINX_SSL_PORT=8443

# API相关端口
CONSOLE_API_URL=http://3.1.38.138:8081
CONSOLE_WEB_URL=http://3.1.38.138:8081
SERVICE_API_URL=http://3.1.38.138:8081
APP_WEB_URL=http://3.1.38.138:8081

配置编排文件

默认编排文件即可, docker-compose不加属性参数默认只会拉起核心组件

启动dify

docker-compose up -d

重置密码:

cd /data/dify
docker-compose exec api /bin/bash
flask reset-password

插件安装

OpenAI-API-compatible

下载地址: OpenAI-API-compatible

1. 下载依赖(python3.12环境), requirements.txt文件来自于插件目录

cat > requirements.txt << EOF
annotated-types==0.7.0
anyio==4.11.0
blinker==1.9.0
certifi==2025.10.5
charset-normalizer==3.4.3
click==8.3.0
dify-plugin==0.7.2
distro==1.9.0
dpkt==1.9.8
flask==3.0.3
gevent==25.5.1
greenlet==3.2.4
h11==0.16.0
httpcore==1.0.9
httpx==0.28.1
idna==3.11
itsdangerous==2.2.0
jinja2==3.1.6
jiter==0.11.0
markupsafe==3.0.3
multidict==6.7.0
openai==2.3.0
packaging==25.0
propcache==0.4.1
pydantic==2.12.0
pydantic-core==2.41.1
pydantic-settings==2.11.0
python-dotenv==1.1.1
pyyaml==6.0.3
regex==2025.9.18
requests==2.32.5
setuptools==80.9.0
sniffio==1.3.1
socksio==1.0.0
tiktoken==0.8.0
tqdm==4.67.1
typing-extensions==4.15.0
typing-inspection==0.4.2
urllib3==2.6.3
werkzeug==3.1.5
yarl==1.22.0
zope-event==6.0
zope-interface==8.0.1
ruff==0.15.11
EOF

# 下载插件(插件文件requirements.txt)
pip download \
    -r requirements.txt \
    -d ./dify_plugin_wheels \
    --platform manylinux2014_aarch64 \
    --only-binary=:all: \
    --python-version 312 \
    --implementation cp \
    --abi cp312 \
    -i http://mirrors.aliyun.com/pypi/simple \
    --trusted-host mirrors.aliyun.com

2. 修改插件配置

本地方式安装一次插件, 由于没有外网环境, 插件会报错, 按如下执行方式修改配置, 修改后再安装一次修, 还是会报错, 先不用管

# 进入宿主机插件目录
cd /data/dify/volumes/plugin_daemon/cwd/langgenius/openai_api_compatible-*

# 修改插件依赖, 删除相关依赖, 修改后配置如下
cat > pyproject.toml << 'EOF'

[project]
name = "openai-api-compatible-GnRzR6cEy"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"

# uv pip compile pyproject.toml -o ./requirements.txt
dependencies = [
]

# uv run black . -C -l 100
# uv run ruff check --fix
[dependency-groups]
dev = [
]
EOF

3. 安装虚拟环境依赖

上传dify_plugin_wheels/data/dify/volumes/plugin_daemon/cwd/langgenius/openai_api_compatible-*插件目录下

# 进入容器
docker exec -it dify-plugin_daemon-1 /bin/bash
# 进入目录
cd /app/storage/cwd/langgenius/openai_api_compatible-*

# 安装依赖
uv pip install --no-index --find-links dify_plugin_wheels -r requirements.txt --python ./.venv/bin/python --link-mode copy

# 验证虚拟环境依赖是否安装成功
uv pip list --python ./.venv/bin/python

4. 再次安装插件(本地方式), 即可成功, 如果添加模型失败, 尝试重启以下服务

docker restart dify-plugin_daemon-1 dify-api-1
Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐