Ошибка Bootstrap с плагином AI, bundle exec rake db:migrate

У меня возникает ошибка при загрузке (bootstrap) в текущей версии 3.5.0.beta7-dev, как только я добавляю плагин AI в конфигурацию контейнера web_only. Тот же самый билд работает нормально без этого плагина.

Изучив страницу Upgrade Error - rake db:migrate index on theme_field_id - #7 by pfaffman, я предполагаю, что корневая причина заключается в отсутствии необходимого расширения на внешнем сервере PostgreSQL 13.20. На сервере установлены расширения hstore, pg_trgm, plpgsql, unaccent, и он также используется для рабочей установки Discourse, которая использует тот же код, но пока без плагина AI.

Может ли кто-то указать, какие расширения PostgreSQL требуются для плагина AI? Я не смог найти эту информацию в Руководстве по самостоятельной установке Discourse AI. Аналогичные сообщения об ошибках, такие как AI Plugin Build Error - 'bundle exec rake db:migrate' failed, описывают другую ситуацию и могут не относиться к моему конкретному сценарию использования…

Актуальные фрагменты файла web_only.yaml:

templates:  
 - "templates/web.template.yml"  
 ## Раскомментируйте следующую строку, чтобы включить слушатель IPv6  
 #- "templates/web.ipv6.template.yml"  
 - "templates/web.ratelimited.template.yml"  
 - "templates/web.socketed.template.yml"  
 ## Раскомментируйте эти две строки, если хотите добавить Lets Encrypt (https)  
 #- "templates/web.ssl.template.yml"  
 #- "templates/web.letsencrypt.ssl.template.yml"

[...]

## настройка подключения к базам данных  
 DISCOURSE_DB_SOCKET: ''  
 DISCOURSE_DB_USERNAME: discourse2  
 DISCOURSE_DB_NAME: discourse2  
 DISCOURSE_DB_PASSWORD: xxx  
 DISCOURSE_DB_HOST: 10.10.10.xx
# кэширование redis на соседнем контейнере  
 DISCOURSE_REDIS_HOST: redis

[...]

## плагины здесь  
## подробности см. по адресу 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  
         - 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
[...]

## для работы за балансировщиком нагрузки haproxy с локальным nginx на хосте контейнера    
 - 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 {
[...]

sudo docker logs -t --tail 1000 web_only

gem install ice_cube -v 0.16.4 -i /var/www/discourse/plugins/discourse-events/gems/3.3.6 --no-document --ignore-dependencies --no-user-install  
Successfully installed ice_cube-0.16.4  
1 gem installed  
gem install icalendar -v 2.8.0 -i /var/www/discourse/plugins/discourse-events/gems/3.3.6 --no-document --ignore-dependencies --no-user-install  
ActiveSupport is required for TimeWithZone support, but not required for general use.  
Successfully installed icalendar-2.8.0  
1 gem installed  
gem install icalendar-recurrence -v 1.1.3 -i /var/www/discourse/plugins/discourse-events/gems/3.3.6 --no-document --ignore-dependencies --no-user-install  
Successfully installed icalendar-recurrence-1.1.3  
1 gem installed  
gem install multipart-post -v 2.4.0 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install  
Successfully installed multipart-post-2.4.0  
1 gem installed  
gem install faraday-multipart -v 1.0.4 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install  
Successfully installed faraday-multipart-1.0.4  
1 gem installed  
gem install event_stream_parser -v 1.0.0 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install  
Successfully installed event_stream_parser-1.0.0  
1 gem installed  
gem install ruby-openai -v 8.1.0 -i /var/www/discourse/plugins/discourse-workflow/gems/3.3.6 --no-document --ignore-dependencies --no-user-install  
Successfully installed ruby-openai-8.1.0  
1 gem installed  
== 20230710171141 EnablePgVectorExtension: migrating ==========================  
-- enable_extension(:vector)  
  
  
  
FAILED  
--------------------  
Pups::ExecError: cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 3914 exit 1>  
Location of failure: /usr/local/lib/ruby/gems/3.3.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'  
exec failed with the params {"cd"=>"$home", "tag"=>"migrate", "hook"=>"db_migrate", "cmd"=>["su discourse -c 'bundle exec rake db:migrate'"]}  
bootstrap failed with exit code 1  
** FAILED TO BOOTSTRAP ** please scroll up and look for earlier error messages, there may be more than one.  
./discourse-doctor may help diagnose the problem.  
3fac1371a3dd8b0d59760e492965c1d7ebb8a09e99549a9483596453f95ce871

Вам нужен GitHub - pgvector/pgvector: Open-source vector similarity search for Postgres · GitHub

Да, спасибо, всё получилось, загрузка прошла успешно. Возможно, эту информацию стоит добавить в руководство по самостоятельному размещению ИИ…

Мне казалось, что плагин должен выполнять этот базовый шаг во время миграции. Меня удивляет, что это ложится на пользователя. К сожалению, мы используем чарт Bitnami, и у меня нет большого контроля над запуском этого расширения через чарт. Мне не хотелось бы делать это вручную, но, похоже, это единственный путь.

Я хотел бы понять, почему плагин не добавляет это в свой скрипт миграции? Была ли для этого конкретная причина?

В моём случае база данных Discourse размещена на внешнем сервере и не входит в стандартный набор контейнеров Discourse. Расширение vector должно быть установлено с другими правами доступа по сравнению с пользователем базы данных для Discourse. Поэтому установка была выполнена вручную, а не как один из этапов процесса инициализации.

Это верно. Вот что сработало для меня.

  • Использование чарта Bitnami Discourse
  • Переопределение Dockerfile для Bitnami PostgreSQL и установка Vector от имени root
  • При запуске PostgreSQL был выполнен скрипт инициализации, чтобы сделать пользователя discourse владельцем Vector
  • Остальное (включая установку плагина) берёт на себя чарт Bitnami

Я узнал это трудным путём. Хотелось бы, чтобы существовала какая-то документация по этому вопросу. В документации плагина должны быть указаны некоторые предварительные требования.