Closed11

Docker compose 環境の Dify v0.15.3 から v1.0.0 への upgrade

ピン留めされたアイテム
Naoki KOBAYASHINaoki KOBAYASHI

Dify (docker compose 環境 )v0.15.3 → v1.0.0 まとめ / 僕の関連する部分しか確認してないよ

Naoki KOBAYASHINaoki KOBAYASHI

現状の Dify バージョン

たぶん Dify 関連のみ...のコンテナ情報

$ docker ps -a
CONTAINER ID   IMAGE                                       COMMAND                  CREATED      STATUS                PORTS                                                                      NAMES
520bd37e8241   nginx:latest                                "sh -c 'cp /docker-e…"   4 days ago   Up 4 days             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   docker-nginx-1
7b171d1b8e1f   langgenius/dify-api:0.15.3                  "/bin/bash /entrypoi…"   4 days ago   Up 4 days             5001/tcp                                                                   docker-worker-1
9d0ce0924027   langgenius/dify-api:0.15.3                  "/bin/bash /entrypoi…"   4 days ago   Up 4 days             5001/tcp                                                                   docker-api-1
d803cafe1109   langgenius/dify-web:0.15.3                  "/bin/sh ./entrypoin…"   4 days ago   Up 4 days             3000/tcp                                                                   docker-web-1
20f11ca4bebf   langgenius/dify-plugin-daemon:0.0.2-local   "/bin/bash -c /app/e…"   4 days ago   Up 4 days             0.0.0.0:5003->5003/tcp, :::5003->5003/tcp                                  docker-plugin_daemon-1
35ce90c4cfeb   semitechnologies/weaviate:1.19.0            "/bin/weaviate --hos…"   4 days ago   Up 4 days                                                                                        docker-weaviate-1
51f9d9b9b470   postgres:15-alpine                          "docker-entrypoint.s…"   4 days ago   Up 4 days (healthy)   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp                                  docker-db-1
81f4112c1980   langgenius/dify-sandbox:0.2.10              "/main"                  4 days ago   Up 4 days (healthy)                                                                              docker-sandbox-1
212d6ffb71e7   redis:6-alpine                              "docker-entrypoint.s…"   4 days ago   Up 4 days (healthy)   6379/tcp                                                                   docker-redis-1
1e9f502be993   ubuntu/squid:latest                         "sh -c 'cp /docker-e…"   4 days ago   Up 4 days             3128/tcp                                                                   docker-ssrf_proxy-1

ローカルリポジトリを更新するよ
https://github.com/langgenius/dify/releases/tag/1.0.0 には git checkout 1.0.0 って書いてるけど、origin/main にマージされているので、main ブランチで良いと思います。

./docker/docker-compose.yaml が v1.0.0 向けになっているのを確認

v1.0.0 のコンテナを既存環境(v0.15.3のデータ群)に対していきなり compose up するのか、指示に従ってみる ( 壊れても良い環境を構築してテストしています )。ログをそのまま眺めたいので docker compose up します。

$ git pull origin main
$ cd ./docker
$ docker compose down
[+] Running 12/12
 ✔ Container docker-plugin_daemon-1   Removed
 ✔ Container docker-weaviate-1        Removed
 ✔ Container docker-worker-1          Removed
 ✔ Container docker-sandbox-1         Removed
 ✔ Container docker-ssrf_proxy-1      Removed
 ✔ Container docker-nginx-1           Removed
 ✔ Container docker-web-1             Removed
 ✔ Container docker-api-1             Removed
 ✔ Container docker-db-1              Removed
 ✔ Container docker-redis-1           Removed
 ✔ Network docker_ssrf_proxy_network  Removed
 ✔ Network docker_default             Removed

$ docker compose up
[+] Running 12/12
 ✔ Network docker_default             Created
 ✔ Network docker_ssrf_proxy_network  Created
 ✔ Container docker-db-1              Created
 ✔ Container docker-sandbox-1         Created
 ✔ Container docker-ssrf_proxy-1      Created
 ✔ Container docker-plugin_daemon-1   Created
 ✔ Container docker-web-1             Created
 ✔ Container docker-redis-1           Created
 ✔ Container docker-weaviate-1        Created
 ✔ Container docker-api-1             Created
 ✔ Container docker-worker-1          Created
 ✔ Container docker-nginx-1           Created
Attaching to api-1, db-1, nginx-1, plugin_daemon-1, redis-1, sandbox-1, ssrf_proxy-1, weaviate-1, web-1, worker-1
plugin_daemon-1  | 2025/03/02 08:38:53 pool.go:32: [INFO]init routine pool, size: 10000
 :
plugin_daemon-1  | 2025/03/02 08:38:53 init.go:141: [PANIC]failed to init dify plugin db: failed to connect to `host=db user=postgres database=postgres`: dial error (dial tcp 192.168.97.5:5432: connect: connection refused)
 :

plugin_daemon がエラー吐いてるけどまぁええでっしゃろ(たぶん)。

Naoki KOBAYASHINaoki KOBAYASHI

Dify にアクセスすると見た目は起動しているように見える

$ docker ps -a
CONTAINER ID   IMAGE                                       COMMAND                  CREATED         STATUS                   PORTS                                                                      NAMES
bbed08ede345   nginx:latest                                "sh -c 'cp /docker-e…"   7 minutes ago   Up 7 minutes             0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   docker-nginx-1
66c5bbe0b7d4   langgenius/dify-api:1.0.0                   "/bin/bash /entrypoi…"   7 minutes ago   Up 7 minutes             5001/tcp                                                                   docker-api-1
eaa2ff82e7bd   langgenius/dify-api:1.0.0                   "/bin/bash /entrypoi…"   7 minutes ago   Up 7 minutes             5001/tcp                                                                   docker-worker-1
14c0398cd10b   langgenius/dify-sandbox:0.2.10              "/main"                  7 minutes ago   Up 7 minutes (healthy)                                                                              docker-sandbox-1
13d099b5ec58   redis:6-alpine                              "docker-entrypoint.s…"   7 minutes ago   Up 7 minutes (healthy)   6379/tcp                                                                   docker-redis-1
64cda3d098f0   postgres:15-alpine                          "docker-entrypoint.s…"   7 minutes ago   Up 7 minutes (healthy)   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp                                  docker-db-1
ae7fe1955475   ubuntu/squid:latest                         "sh -c 'cp /docker-e…"   7 minutes ago   Up 7 minutes             3128/tcp                                                                   docker-ssrf_proxy-1
f724e1872062   langgenius/dify-web:1.0.0                   "/bin/sh ./entrypoin…"   7 minutes ago   Up 7 minutes             3000/tcp                                                                   docker-web-1
b3725cdf8ed6   semitechnologies/weaviate:1.19.0            "/bin/weaviate --hos…"   7 minutes ago   Up 7 minutes                                                                                        docker-weaviate-1
8784f3f894f6   langgenius/dify-plugin-daemon:0.0.3-local   "/bin/bash -c /app/e…"   7 minutes ago   Up 7 minutes             0.0.0.0:5003->5003/tcp, :::5003->5003/tcp                                  docker-plugin_daemon-1

plugin_daemon は PANIC 起こしてたけどちゃんと起動してるっぽいね。migration しなくても動くのか? 手順に従ってやるのが賢いので手順通りにやりましょう。

Naoki KOBAYASHINaoki KOBAYASHI

poetry を実行...と書いてるね、コンテナ上でコマンド実行したい。v1.0.0 beta バージョン触った時に API コンテナ上で実行した記憶があるので

Plugin Migrate

docker exec -d docker-api-1 poetry run flask extract-plugins --workers=20
docker exec -d docker-api-1 poetry run flask install-plugins --workers=2

ん?全くログは吐かないけどええんか?

DB Migrate

docker exec -d docker-api-1 poetry run flask db upgrade
docker exec -d docker-api-1 poetry run flask migrate-data-for-plugin

やっぱりログは動かないね、ちょっと不安なのでコンテナに入ってコマンド実行してみる。

OrbStack 便利だねー

あぁ全然叩けてなかったわ。コンテナに入ってちゃんとコマンド実行しましょう

対象のコンテナは docker-api-1 で ok です。output ファイル指定部分は Enter で ok デフォルトのファイル名で動くようにできています。

$ poetry run flask extract-plugins --workers=20
2025-03-02 09:00:05.723 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 10 threads.
2025-03-02 09:00:06.950 INFO [MainThread] [_client.py:1038] - HTTP Request: GET https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json "HTTP/1.1 200 OK"
Output file [plugins.jsonl]:
Starting extract plugins.
Migrating models/tools to new plugin Mechanism
Total tenant count: 1
Current time: 2023-04-03 08:59:24, Started at: 2025-03-02 09:00:16.545998
 :

$ poetry run flask install-plugins --workers=2
poetry run flask install-plugins --workers=2
2025-03-02 09:00:32.794 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 10 threads.
2025-03-02 09:00:33.954 INFO [MainThread] [_client.py:1038] - HTTP Request: GET https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json "HTTP/1.1 200 OK"
Input file [plugins.jsonl]:
Output file [installed_plugins.jsonl]:
Starting install plugins.
2025-03-02 09:00:37.517 INFO [MainThread] [plugin_migration.py:304] - Extracting unique plugins from plugins.jsonl
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:01<00:00,  1.79it/s]
2025-03-02 09:00:38.649 INFO [MainThread] [plugin_migration.py:342] - Installing 2 plugin instances for fake tenant bd1f48bd58924a10adbdb1e8e323b63e
 :

$ poetry run flask db upgrade
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.

$ poetry run flask migrate-data-for-plugin
2025-03-02 09:04:36.339 INFO [MainThread] [utils.py:162] - NumExpr defaulting to 10 threads.
2025-03-02 09:04:37.618 INFO [MainThread] [_client.py:1038] - HTTP Request: GET https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json "HTTP/1.1 200 OK"
Starting migrate data for plugin.
Migrating [providers] data for plugin
Migrate [providers] data for plugin completed, total: 0
Migrating [provider_models] data for plugin
Migrate [provider_models] data for plugin completed, total: 0
Migrating [provider_orders] data for plugin
Migrate [provider_orders] data for plugin completed, total: 0
Migrating [tenant_default_models] data for plugin
Migrate [tenant_default_models] data for plugin completed, total: 0
Migrating [tenant_preferred_model_providers] data for plugin
Migrate [tenant_preferred_model_providers] data for plugin completed, total: 0
Migrating [provider_model_settings] data for plugin
Migrate [provider_model_settings] data for plugin completed, total: 0
Migrating [load_balancing_model_configs] data for plugin
Migrate [load_balancing_model_configs] data for plugin completed, total: 0
Migrating [datasets] data for plugin
Migrate [datasets] data for plugin completed, total: 0
Migrating [embeddings] data for plugin
Migrate [embeddings] data for plugin completed, total: 0
Migrating [dataset_collection_bindings] data for plugin
Migrate [dataset_collection_bindings] data for plugin completed, total: 0
Migrating [tool_builtin_providers] data for plugin
Migrate [tool_builtin_providers] data for plugin completed, total: 0
Migrate data for plugin completed.

よさそう。

Naoki KOBAYASHINaoki KOBAYASHI

Dify v1.0.0 のフロントページは正しく動いてそう。DevTool でネットワーク見ててもエラーないね。
設定正しいか?見ていこうか。

モデルプロバイダが Plugin になった大きく変わってるはず

v0.15.3 -> v1.0.0 の Migrate 確認

Gemini

うはははははは、Gemini の設定は全てのモデルが有効になってるな、必要に応じて設定戻す。Gemini 2.0 Flash Exp と Gemini 2.0 pro exp 02-05 の2つしか有効にしてなかったはず

Bedrock

おぉ完璧じゃん!

システムモデル設定

システム推論モデルは Gemini pro exp 02-05 になってたんだけどここは吹っ飛んでるね

アプリの状況

うーん、Gemini 2.0 Flah exp を指定していたチャットボットアプリ、プロンプトとナレッジ設定がなくなってる気がするなぁー。ナレッジは再設定したら使えたのは朗報。

ワークフローで利用している LLM に設定してる Gemini 2.0 pro exp 02-05 が再設定しないと使えないな、同じ名前で存在してるんだけど使えない.....再設定して利用する。

Gemini のモデルプロバイダー設定正しいように見えたけど、API キーがちゃんと移行できてないのか?キー設定し直さないと動かない...

Gemini 周りがめちゃ怪しんだけど、Bedrock はナレッジ作成(埋め込みモデル)くらいにしか使ってなかったからわからんなぁー、これ会社のテスト環境(いろんな人が使ってる)アップデートしてもいいものか、ごめん!プロンプトが残ってて、ナレッジが壊れなければ、プロバイダ再設定くらいならええと思うのだが....。ディレクトリ丸ごとバックアップしてやってみるか!

Naoki KOBAYASHINaoki KOBAYASHI

Migration 手順間違ってないよね?と思う Upgrade 結果でした。
まぁ、手動で直せる程度かな..とは思う。1つチャットボットタイプのアプリ、プロンプトが丸ごとなくなってる気がしたのだが、これは僕が保存(公開)してなかっただけなのか。最後にバージョンアップ検証用に作ってやるだから可能性はある。

Naoki KOBAYASHINaoki KOBAYASHI

AWS プロバイダーから rerank モデルが表示されなく(扱えなく)なってるな

Naoki KOBAYASHINaoki KOBAYASHI

すごく前から v1.0.0 ( plugin システム ) の準備してたから、そりゃいろいろ考慮漏れあるよなーと思う。会社のテスト環境もえい!ってあげたみた。

さぁーと見た感じ、盛大に壊れてるものはなさそう。Bedrock の Rerank モデルが使えない...のが痛いけど、今はテスト環境だから Rerank モデル諦めてもらって先に進めよう。

Naoki KOBAYASHINaoki KOBAYASHI

v0.15.3 で実装されていた Bedrock のモデルが戻ってきそうな PR. が立てられた
https://github.com/langgenius/dify-official-plugins/pull/363

Bedrock モデルプロバイダー周辺、あーん?って感じになってる、
https://github.com/langgenius/dify-official-plugins/pull/369

https://github.com/langgenius/dify-official-plugins/pull/370

  • PR#369 を Revert.... する PR

もうちょっとちゃんと動作フェーズが入る仕組みが必要そう

このスクラップは4ヶ月前にクローズされました