AI 플러그인에서 Bootstrap 오류 발생, bundle exec rake db:migrate

현재 3.5.0.beta7-dev 버전에서 AI 플러그인을 web_only 컨테이너 설정에 포함하는 즉시 부트스트랩 오류가 발생하고 있습니다. 이 플러그인이 없으면 동일한 빌드가 정상적으로 작동합니다.

Upgrade Error - rake db:migrate index on theme_field_id - #7 by pfaffman 포럼 글을 읽어본 결과, 근본 원인은 (외부) postgres 서버 13.20에서 확장 기능이 누락된 것 때문일 것으로 추정됩니다. 해당 서버에는 hstore, pg_trgm, plpgsql, unaccent 확장 기능이 설치되어 있으며, 동일한 코드를 사용하지만 아직 AI 플러그인이 없는 프로덕션 discourse 설치에도 사용되고 있습니다.

누군가 AI 플러그인에 필요한 postgres 확장 기능을 확인해 주실 수 있을까요? Discourse AI - Self-Hosted Guide 에서 이 정보를 찾을 수 없었습니다. 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
[...]

## 컨테이너 호스트의 로컬 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 {
[...]

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 가 필요합니다.

네, 감사합니다. 이게 문제였습니다. 이제 부트스트랩이 성공적으로 완료되었습니다. 이 정보가 AI 셀프호스팅 가이드에 추가되어야 할 것 같네요 …

이 플러그인이 마이그레이션 중에 이 기본적인 단계를 수행해야 한다고 생각했습니다. 사용자가 직접 실행해야 한다는 점이 놀랍습니다. 불행히도 우리는 bitnami 차트를 사용 중이므로, 차트를 통해 이 확장을 실행하는 데 대해 많은 제어 권한이 없습니다. 수동으로 처리하는 것은 싫지만, 그것이 앞으로의 방향인 것 같습니다.

왜 플러그인이 마이그레이션 스크립트에 이를 추가하지 않는지 이해하고 싶습니다. 특정 이유가 있었나요?

저의 경우, Discourse의 데이터베이스 부분은 외부 서버에 위치해 있으며 Discourse 컨테이너의 표준 번들 일부가 아닙니다. vector 확장 기능은 Discourse의 데이터베이스 사용자와는 다른 권한으로 설치되어야 합니다. 따라서 설치는 부트스트랩 과정의 한 단계로 수행될 수 없으며 수동으로 진행해야 했습니다.

맞습니다. 제가 성공적으로 적용했던 방법은 다음과 같습니다.

  • Bitnami Discourse 차트 사용
  • Bitnami Postgres의 Dockerfile을 오버라이드하여 root 권한으로 Vector 설치
  • Postgres 시작 시 초기화 스크립트를 실행하여 discourse 사용자로 Vector의 소유자를 변경
  • 나머지 작업(플러그인 설치 포함)은 Bitnami 차트가 처리

이건 시행착오를 통해 깨달은 내용입니다. 이와 관련된 문서가 있었으면 좋겠습니다. 플러그인 문서에 사전 요구 사항에 대한 언급이 포함되어야 합니다.