RDS 부트스트랩 중 문제 발생 — 인증서 파일을 열 수 없음

데이터베이스는 RDS에 있는 비교적 표준적인 설치 환경입니다. 원래 13.2 버전이었는데 방금 15.2로 업그레이드했습니다. 기존 컨테이너는 정상적으로 작동하고 있습니다.

새 이미지를 부트스트랩하면 데이터베이스 마이그레이션과 에셋 사전 컴파일이 수행되고,

그 다음

                                                                                                                                                                            
I, [2023-12-20T20:16:12.865112 #1]  INFO -- : > cd /var/www/discourse && sudo -E -u discourse bundle exec rake s3:upload_assets                                              
Plugin name is 'discourse-linkedin-auth', but plugin directory is named 'discourse-plugin-linkedin-auth'                                                                     
Plugin name is 'stemaway-experience-bbcodes', but plugin directory is named 'experience-bbcodes'                                                                             
Plugin name is 'discourse-badge-search', but plugin directory is named 'stemaway-badge-search'                                                                               
Plugin name is 'points-plugin', but plugin directory is named 'tacks-plugin'                                                                                                 
Plugin name is 'discourse-group-assign-by-custom-field', but plugin directory is named 'ucf-group-assignment'                                                                
rake aborted!                                                                                                                                                                
ActiveRecord::NoDatabaseError: We could not find your database: discourse. Which can be found in the database configuration file located at config/database.yml. (ActiveRecor
d::NoDatabaseError)                                                                                                                                                          
                           

그리고 나중에 이런 내용도 나옵니다:

Caused by:                                                                                                                                                                   
PG::ConnectionBad: connection to server at "172.31.x.y", port 5432 failed: could not open certificate file "/root/.postgresql/postgresql.crt": Permission denied (PG::Connec
tionBad)                                                                                                                                                                     
connection to server at "172.31.x.y", port 5432 failed: FATAL:  no pg_hba.conf entry for host "172.31.x.y", user "postgres", database "discourse", no encryption   
...
Pups::ExecError: cd /var/www/discourse && sudo -E -u discourse bundle exec rake s3:upload_assets failed with return #<Process::Status: pid 7133 exit 1>                      

마이그레이션과 사전 컴파일은 되는데 에셋 업로드는 안 되는 것이 (제 생각에는) 말이 안 됩니다.
빌드 중인 컨테이너에 들어가면 ENV에 있는 자격 증명 정보를 사용하여 postgres에 연결할 수 있습니다.

tmux에서 전체 로그를 추출하는 작업을 진행하겠습니다. . .글쎄, 버퍼가 매우 작아서 여기에 다 담기지가 않습니다. 더 큰 버퍼를 설정하고 다른 부트스트랩을 실행한 뒤, 전체 로그를 어딘가에 올려보겠습니다.

결국 필요한 건

env:
  PGSSLCERT: /tmp/postgresql.crt

이걸 어떻게 알아냈는지는 모르겠지만, 스테이징 사이트의 yml 파일에는 있지만 프로덕션에는 없었습니다. 그리고 최근까지 잘 작동했습니다. 데이터베이스 마이그레이션은 문제없이 진행되었고, 자산(assets)을 사전 컴파일하려고 할 때까지 실패하지 않았기 때문에 정말 기이합니다.