仮想マシンにおけるDifyモデルのデプロイ

仮想マシン環境でのDifyモデル展開手順

1. 仮想マシン環境の準備

推奨環境仕様:

  • OS: Ubuntu 20.04 LTS 以上
  • CPU: 2コア以上
  • メモリ: 4GB以上
  • ストレージ: 20GB以上の空き容量

2. 必須ソフトウェアのインストール

Dockerのセットアップ

# 依存パッケージのインストール
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg

# Docker公式GPGキーの追加
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

# リポジトリの登録
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Docker Engineのインストール
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 動作確認
sudo docker run hello-world

Gitのインストール

sudo apt-get install -y git
git --version

3. Difyリポジトリのクローン

git clone https://github.com/langgenius/dify.git
cd dify

4. 依存関係のセットアップ

# Python環境の準備
sudo apt-get install -y python3.10 python3-pip python3.10-venv

# 仮想環境の作成と有効化
python3 -m venv venv
source venv/bin/activate

# 依存パッケージのインストール
pip install -r requirements.txt

5. データベースの設定

# PostgreSQLのインストール
sudo apt-get install -y postgresql postgresql-contrib

# サービス起動
sudo systemctl start postgresql

# ユーザーとデータベースの作成
sudo -u postgres psql -c "CREATE USER difyuser WITH PASSWORD 'difypassword';"
sudo -u postgres psql -c "CREATE DATABASE difydb OWNER difyuser;"

6. 設定ファイルの編集

.envファイルを編集:

DATABASE_URL=postgresql://difyuser:difypassword@localhost:5432/difydb
REDIS_URL=redis://localhost:6379

7. アプリケーションの起動

# バックエンドサービスの起動
python app.py

# 別ターミナルでワーカーの起動
celery -A tasks worker --loglevel=info

タグ: Dify 仮想マシン デプロイ Docker PostgreSQL

7月25日 23:56 投稿