Discourse でのブートストラップの失敗のトラブルシューティング

新しい「プリバンドリング」プロセスにまだ苦労しています。テストインスタンスでブートストラップが失敗し、原因がわかりません。これは外部の PostgreSQL データベースを使用する設定であることに注意してください。コンテナは HAProxy の背後で SSL アクセラレータとして実行されています。ここでは web_only コンテナのみをブートストラップしています。現在のビルドバージョン(ブートストラップ前)は 3.5.0.beta8-dev です:Commits · discourse/discourse · GitHub

現在失敗している yml ファイルは以下の通りです:

# 重要:Discourse ユーザーに対して Postgres で秘密のパスワードを設定してください
# TODO:このテンプレート内の SOME_SECRET を変更してください

templates:
  - "templates/web.template.yml"
  ## 次の行のコメントアウトを解除して IPv6 リスナーを有効化
  #- "templates/web.ipv6.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"
  ## Lets Encrypt (https) を追加したい場合は、この 2 行のコメントアウトを解除
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## このコンテナが公開すべき TCP/IP ポートはどれか?
## Discourse を Apache や nginx のような他の Web サーバーとポートを共有したい場合は、
## https://meta.discourse.org/t/17247 を参照
expose:
  - "80:80"   # http
  - "443:443" # https

# 'links' キーを使用してコンテナをリンク(Docker --link フラグの使用)
links:
  - link:
      name: redis
      alias: data

# Docker に追加の引数を渡す?
# docker_args:

params:
  ## このコンテナが使用する Git リビジョンは?(デフォルト: tests-passed)
  #version: tests-passed

env:
  LC_ALL: en_US.UTF-8
  LANG: en_US.UTF-8
  LANGUAGE: en_US.UTF-8
  DISCOURSE_DEFAULT_LOCALE: de

  ## 同時にサポートされる Web リクエスト数?メモリと CPU コア数に依存
  ## bootstrap により検出された CPU に基づいて自動的に設定されますが、上書きすることも可能
  UNICORN_WORKERS: 4

  ## TODO:この Discourse インスタンスが応答するドメイン名
  DISCOURSE_HOSTNAME: 'forum2.netzwissen.de'

  ## 上記で指定したホスト名と同じ (-h オプション) でコンテナを起動したい場合は、
  ## 以下の行のコメントアウトを解除(デフォルトは "$hostname-$config")
  #DOCKER_USE_HOSTNAME: true

  ## TODO:初期登録時に管理者および開発者として登録される、カンマ区切りのメールアドレスリスト
  ## 例:'user1@example.com,user2@example.com'
  DISCOURSE_DEVELOPER_EMAILS: 'admin@netzwissen.de'

  ## TODO:新しいアカウントの検証と通知送信に使用する SMTP メールサーバー
  # SMTP アドレス、ユーザー名、パスワードは必須
  # 警告:SMTP パスワードに '#' 文字が含まれていると問題が発生する可能性があります!
  DISCOURSE_SMTP_ADDRESS: mail.netzwissen.de
  DISCOURSE_SMTP_PORT: 587
  DISCOURSE_SMTP_USER_NAME: discourse@netzwissen.de
  DISCOURSE_SMTP_PASSWORD: [xxxxxxxxxxxxxxxxx}
  #DISCOURSE_SMTP_ENABLE_START_TLS: true           # (オプション、デフォルト true)
  #DISCOURSE_SMTP_DOMAIN: discourse.example.com    # (一部のプロバイダーで必須)
  DISCOURSE_NOTIFICATION_EMAIL: discourse@netzwissen.de    # (通知を送信するアドレス)

  ## Lets Encrypt テンプレートを追加した場合、以下をコメントアウト解除して無料の SSL 証明書を取得
  #LETSENCRYPT_ACCOUNT_EMAIL: me@example.com

## データベースへの接続設定
  DISCOURSE_DB_SOCKET: ''
  DISCOURSE_DB_USERNAME: [xxxxxxxxxxx]
  DISCOURSE_DB_NAME: [xxxxxxxxxxxxxxx]
  DISCOURSE_DB_HOST: [xxxxxxxxxxxxxxx]
  DISCOURSE_DB_PASSWORD: [xxxxxxxxxxxxxxx]
  ## 隣接コンテナ上の redis キャッシング
  DISCOURSE_REDIS_HOST: redis

  ## この Discourse インスタンスの HTTP または HTTPS CDN アドレス(プルするように設定)
  ## 詳細は https://meta.discourse.org/t/14857 を参照
  #DISCOURSE_CDN_URL: https://discourse-cdn.example.com

  ## IP アドレスの検索に使用する MaxMind のジオロケーション IP アカウント ID とライセンスキー
  ## 詳細は https://meta.discourse.org/t/-/173941 を参照
  #DISCOURSE_MAXMIND_ACCOUNT_ID: 123456
  #DISCOURSE_MAXMIND_LICENSE_KEY: 1234567890123456

volumes:
  - volume:
      host: /mnt/data/discourse/shared/web-only
      guest: /shared
  - volume:
      host: /mnt/data/discourse/shared/web-only/log/var-log
      guest: /var/log

## プラグインはここに記述
## 詳細は https://meta.discourse.org/t/19157 を参照
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/discourse/discourse-shared-edits.git
# 一部のプラグインはコアにバンドルされたため削除
# https://meta.discourse.org/t/bundling-more-popular-plugins-with-discourse-core/373574
## = 現在バンドル済み
##          - git clone https://github.com/discourse/discourse-chat-integration.git
##          - git clone https://github.com/discourse/discourse-openid-connect.git
##          - git clone https://github.com/discourse/discourse-calendar.git
##          - git clone https://github.com/angusmcleod/discourse-events.git
##          - git clone https://github.com/discourse/discourse-data-explorer.git
##          - git clone https://github.com/discourse/discourse-reactions.git
##          - git clone https://github.com/discourse/discourse-chat.git
##          - git clone https://github.com/discourse/discourse-ai.git
##          - git clone https://github.com/discourse/discourse-topic-voting.git
##          - git clone https://github.com/discourse/discourse-post-voting.git
##          - git clone https://github.com/discourse/discourse-user-notes.git
##          - git clone https://github.com/discourse/discourse-solved.git
          - git clone https://github.com/discourse/discourse-docs-card-filter.git
          - git clone https://github.com/discourse/discourse-doc-categories.git
##          - git clone https://github.com/discourse/discourse-assign.git
##          - git clone https://github.com/discourse/discourse-templates.git
          - git clone https://github.com/discourse/discourse-saved-searches.git
          - git clone https://github.com/discourse/discourse-tooltips.git
          - git clone https://github.com/discourse/discourse-category-experts.git
          - git clone https://github.com/discourse/discourse-activity-pub.git
          - git clone https://github.com/discourse/discourse-follow.git
          - git clone https://github.com/nathan-nz/discourse-wikified-posts.git
          - git clone https://github.com/discourse/discourse-whos-online.git
          - git clone https://github.com/merefield/discourse-workflow.git

## 覚えておいてください、これは YAML 構文です。名前の付いたブロックは 1 つしか持てません
run:
  - exec: echo "Beginning of custom commands"

  ## root へのパスワードログインを設定したい場合は、以下の行のコメントアウトを解除して変更
  ## 以下のいずれか 1 行のみを使用
  #- exec: /usr/sbin/usermod -p 'PASSWORD_HASH' root
  - exec: /usr/sbin/usermod -p "$(mkpasswd -m sha-256 'xxxxxxxxxxxxxxx')" root

## コンテナホスト上のローカル nginx とともに HAProxy ロードバランサーの背後で動作する場合
  - replace:
      filename: /etc/nginx/conf.d/discourse.conf
      from: "types {"
      to: |
        set_real_ip_from 127.0.0.1/24;
        set_real_ip_from 10.0.0.0/24;
        real_ip_header X-Forwarded-For;
        real_ip_recursive on;
        proxy_set_header Host $http_host;
        proxy_set_header X-Request-Start "t=${msec}";
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https; # $thescheme の置き換え;
        proxy_set_header X-Real-IP $remote_addr;
        types {

  ## 追加のユーザーを許可したい場合は、以下の行のコメントアウトを解除して変更
  #- exec: ssh-import-id username
  #- exec: ssh-import-id anotherusername

  - exec: echo "End of custom commands"
  - exec: awk -F\# '{print $1;}' ~/.ssh/authorized_keys | awk 'BEGIN { print "Authorized SSH keys for this container:"; } NF>=2 {print $NF;}'

ymll に rm -rf ブロックを追加しても、

- rm -rf discourse-chat-integration  
- rm -rf discourse-openid-connect         
- rm -rf discourse-calendar         
- rm -rf discourse-events         
- rm -rf discourse-data-explorer         
- rm -rf discourse-reactions         
- rm -rf discourse-chat         
- rm -rf discourse-ai         
- rm -rf discourse-topic-voting         
- rm -rf discourse-post-voting         
- rm -rf discourse-user-notes         
- rm -rf discourse-solved         
- rm -rf discourse-assign         
- rm -rf discourse-templates

ブートストラップは引き続き以下のエラーで失敗します:

/usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups.rb
/usr/local/bin/pups --stdin

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 669 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.3.0/lib/pups/exec_command.rb:131:in `spawn'
exec failed with the params {"cd"=>"$home", "tag"=>"migrate", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}

これは「bundle exec rake db:migrate」でのデータベースマイグレーションのエラーと解釈できます。しかし、根本原因は何でしょうか?discourse2 データベースには、以前にインストールされていた discourse-ai プラグインに必要なベクトル拡張機能が既に存在しています:

postgres=# \c discourse2  
psql (15.12 (Ubuntu 15.12-1.pgdg22.04+1), server 13.20 (Ubuntu 13.20-1.pgdg22.04+1))  
You are now connected to database "discourse2" as user "postgres".  
discourse2=# \dx  
                                   List of installed extensions  
  Name   | Version |   Schema   |                            Description                               
----------+---------+------------+-------------------------------------------------------------------  
hstore   | 1.7     | public     | data type for storing sets of (key, value) pairs  
pg_trgm  | 1.5     | public     | text similarity measurement and index searching based on trigrams  
plpgsql  | 1.0     | pg_catalog | PL/pgSQL procedural language  
unaccent | 1.1     | public     | text search dictionary that removes accents  
vector   | 0.8.0   | public     | vector data type and ivfflat and hnsw access methods  
(5 rows)

その後、yml 内の「git clone」行がすべてコメントアウトされているにもかかわらず、プラグインのヒントが表示されます:

---
HINT: The plugin 'discourse-openid-connect' is now bundled with Discourse and should not be included in your container configuration.
Remove the line 'git clone https://github.com/discourse/discourse-openid-connect' from your containers/web_only.yml file, then try again.
For more information, see https://meta.discourse.org/t/373574
---

正直なところ、今は少し行き詰まっています ::sleepy_face:

free -h は何を表示しますか?

root@docker3a:/var/discourse/containers# free -h
合計 使用中 空き 共有 バッファ/キャッシュ 利用可能
メモリ: 3,8Gi 2,0Gi 1,1Gi 3,8Mi 969Mi 1,8Gi

おそらく4GBのスワップ

申し訳ありません、私のミスです。出力が途中で切れていました。

root@docker3a:~# free -h
合計 使用中 空き 共有 バッファ/キャッシュ 利用可能
メモリ: 3.8Gi 2.0Gi 1.1Gi 3.8Mi 971Mi 1.8Gi
スワップ: 974Mi 0B 974Mi

VMにはすでに4GBのメモリがあります。さらに2GBを追加し、別の./launcher rebuild web_only^を実行しましたが、同じエラーが発生しました。そのため、ここではスペース関連のビルドの問題ではないと思います…

RAM 8 GB に対して 2 GB のスワップが必要でした。

8 GB RAM で再度試しましたが、同じエラー結果でした。これは Proxmox ホスト (Features - Proxmox Virtual Environment) 上のカーネルベース仮想マシン (KVM) です。

QEMU/KVM ゲストは、ゲスト OS が必要とするメモリをホストに要求しますが、ゲスト OS が不要になった場合でもメモリをホストに自動的に返却しません。ホストがメモリを必要とする場合、カーネルはプロセスに未使用の RAM を返却するように要求するため、QEMU はメモリを回復しようとしますが、ゲスト OS が最初に解放することに依存します。

4 GB RAM と 4 CPU のセットアップでは、discourse-ai プラグインを使用してもメモリの問題は発生しませんでした。このバンドル発表後にのみブートストラップの問題が発生しました…

この discourse-openid-connect プラグインは、yml ファイルのどこかにありますか?

これは移行の問題です。移行に失敗したものを探すために上にスクロールできますか?

この discourse-openid-connect プラグインは、YAML ファイルのどこかにありますか?

これは移行の問題ですが、移行に失敗したものを探すために上にスクロールできますか?

これまではプラグインリストに discourse-openid-connect が含まれていました。「post-bundling build」のために削除しました。現在、ビルド YAML には次のプラグインのみが残っています。

## 非バンドルプラグイン
- git clone https://github.com/discourse/docker_manager.git\\`
- git clone https://github.com/discourse/discourse-shared-edits.git`
- git clone https://github.com/discourse/discourse-docs-card-filter.git`
- git clone https://github.com/discourse/discourse-doc-categories.git`
- git clone https://github.com/discourse/discourse-saved-searches.git`
- git clone https://github.com/discourse/discourse-tooltips.git`
- git clone https://github.com/discourse/discourse-category-experts.git`
- git clone https://github.com/discourse/discourse-activity-pub.git`

  • git clone https://github.com/discourse/discourse-follow.git
  • git clone ``https://github.com/nathan-nz/discourse-wikified-posts.git
  • git clone https://github.com/discourse/discourse-whos-online.git
  • git clone \\\https://github.com/merefield/discourse-workflow.git\\

ビルドは「bundle exec rake db:migrate」でクラッシュするようですが、その数行上で次のメッセージが表示されます。

Gem::LoadError: can't activate multipart-post-2.4.0, already activated multipart-post-2.4.1 (Gem::LoadError)

[…]
discourse-wikified-posts は既に最新の互換性のあるバージョンです discourse-workflow は既に最新の互換性のあるバージョンです docker_manager は既に最新の互換性のあるバージョンです I,
[2025-07-28T06:34:13.916393 #1] INFO -- : `> cd /var/www/discourse `&`& su discourse -c 'bundle exec rake db:migrate' rake aborted! Gem::LoadError: can't activate multipart-post-2.4.0, already activated multipart-post-2.4.1 (Gem::LoadError) /var/www/discourse/lib/plugin_gem.rb:25:in `load' /var/www/discourse/lib/plugin/instance.rb:861:in `gem' […]

Ruby については何も知りませんが、これは multipart-post-2.4.0multipart-post-2.4.1 の間のパッケージ競合でしょうか?

よろしくお願いします!
Thommie

それが原因で、私のビルドのうち2つが倒壊しました。CDCKのプラグインの少なくとも1つは古いバージョンを使用しています。

これはシステムが設計どおりに動作しています。

GemfileとGemfile.lockを使用してgem依存関係を管理する場合、dependbotが更新をスキャンし、内部プロセスを使用して最新の状態に保ちます。

プラグインデザイナーは、コアに出荷されるgem依存関係に依存できるようになりました。

これは、プラグインのplugin.rbからmultipart-post削除し、使用している場所から単純にrequireする必要があることを意味します。

プラグイン作成者が心配する必要のあることが一つ減りました。

ありがとうございます。参考になるフィードバックです。

@Thomas_Rother プラグインから依存関係を削除しました。ビルドをもう一度試してください。

@merefield @sam :smiley: - 成功しました!! Robertsのプラグイン GitHub - merefield/discourse-workflow: A workflow system for Topics that implements a configurable multi-stage process のコミット 6be7a44 でビルドが成功しました。分析と修正に感謝します!