配置 Discourse 以使用单独的 PostgreSQL 服务器

我有一个新安装的 Discourse 实例,通过 Docker 在 Google Cloud 的 VM 上运行。我目前已启用文件上传和 Discourse 备份到 Google Cloud 的存储桶,并且在遵循 为上传配置 S3 兼容对象存储提供商 线程 中的说明后,这些功能运行正常。我可以在存储桶中看到测试上传,并且当我查看上传 URL 时,所有上传都显示来自 CDN 的正确 URL,因此它们似乎能正确地从存储桶中拉取。

然后,我在 Google Cloud 上创建了一个 PostgreSQL 15.2 实例,并执行了第一个帖子中概述的数据库设置过程,并配置了 app.yml 文件。Google Cloud 上 PostgreSQL 的默认端口是 5432,所以我省略了这些行。
如果我在 app.yml 配置中使用 postgres 实例的公共 IP 地址,当我重建应用程序时,我会得到以下结果:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse & su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1024 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "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.
a6a71b00bce378aa6334ae1c9fe103778d260bb699fe598f9685689e8b5ce450

只是为了看看发生了什么,我尝试使用 postgres 实例的其他 IP 地址。
如果我使用 postgres 实例的私有 IP 地址,我会得到以下结果:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse & su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1024 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "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.
7333126c522eb51ace4d55ea89803eea54b96704baab70c322008cf2836ba47a

如果我使用 postgres 实例的传出 IP 地址,我会得到以下结果:

FAILED
--------------------
Pups::ExecError: cd /var/www/discourse & su discourse -c 'bundle exec rake db:migrate' failed with return #<Process::Status: pid 1026 exit 1>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.1.1/lib/pups/exec_command.rb:117:in `spawn'
exec failed with the params {"cd"=>"$home", "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.
c588d2b6977b9e7d493b0b59bc694369cb7c2219de67d5886112ed16312626ae

使用所有不同的 IP 地址,失败的消息都非常相似,并且 postgres 数据库根本没有收到任何数据或连接。有人能告诉我我哪里做错了什么吗?

另外,我的问题是否是由 VM 实例上未使用 Cloud SQL Auth Proxy 引起的?如果是,我想我必须构建一个脚本来运行代理并在应用程序重建之前对其进行计时。有人对此有任何见解吗?

感谢大家的时间。