大家好,Discourse 社区!
我在 gitpod.io 工作,这是一个面向 GitHub 的免费一键式 IDE。我们目前使用 Spectrum 作为社区平台,但遇到了一些问题,因此非常希望能搭建一个 Discourse 实例进行体验,并考虑未来迁移。
如果可能的话,我们希望使用自己的 Google Cloud 账户来实现。能否请您指点一下方向?例如,新的 Google Cloud Run 是否适合运行 Discourse 实例?
此外,由于我们的使命是全面自动化所有开发环境设置(至少针对开源项目),我希望为 Discourse 贡献一个完全自动化的部署方案,让贡献者能够一键在线启动一个可立即编码的 Discourse 环境(而不是阅读冗长的设置说明,并在当前设备上手动安装和配置大量依赖项)。我已经基于 @notriddle (你好!)为 Janitor 开发的优秀 Discourse 自动化部署方案 开始了相关工作。
不过,我目前遇到了一个问题:最近该部署方案因缺少“polls”表而失败。我暂时还不清楚如何修复,但会继续调查。只是觉得应该在这里提一下。
marianord
(Mariano Rodriguez)
2019 年9 月 17 日 12:24
2
有可能,但这并不简单。Discourse 并非无状态容器,而 Google Cloud Run 正是为此设计的。因此,你需要一种方式为 Discourse 中保存的数据(如上传文件、头像、数据库)添加某种持久化卷。
我建议使用普通的 Google Compute Engine 实例即可。借助某种脚本或基础设施管理工具,你应该能够自动化部署新的 Discourse 实例。这份指南可能也会对你有帮助:Install Discourse on Ubuntu or Debian for Development
david
(David Taylor)
2019 年9 月 17 日 12:54
3
你使用的是哪份安装说明?如果缺少 polls 表,说明你尚未运行插件迁移。在开发模式下,它们应自动运行。在测试模式下,你需要在 rake db:migrate 命令前添加 LOAD_PLUGINS=1。
感谢 @marianord 和 @david 的回复!
这听起来比使用 Cloud Run 更合理,因为从 Discourse 容器中提取所有状态可能需要一些时间。谢谢你指向这份指南!我会尝试按照它来设置 Compute 实例,并在这里汇报我的发现。
david:
你使用的是哪套设置说明?
我正在遵循 https://github.com/discourse/discourse/blob/master/docs/DEVELOPER-ADVANCED.md。
我遇到的确切错误是:
== 从 /workspace/discourse/db/fixtures/990_settings.rb 导入种子数据
Discourse 主机名:localhost 不是有效的邮件域名!
== 从 /workspace/discourse/db/fixtures/990_topics.rb 导入种子数据
rake 中止!
ActiveRecord::StatementInvalid: PG::UndefinedTable: 错误:关系 "polls" 不存在
LINE 8: WHERE a.attrelid = '"polls"'::regclass
^
在尝试执行以下操作时:
bundle exec rake db:create db:migrate &&
RAILS_ENV=test bundle exec rake db:create db:migrate
我还尝试添加这一行:
RAILS_ENV=development bundle exec rake db:create db:migrate
但毫无成效。
非常感谢你的提示!我会尝试一下,并在这里汇报结果。(抱歉在一个帖子里问了两个问题!希望不会让讨论变得太混乱。)
pfaffman
(Jay Pfaffman)
2019 年9 月 17 日 14:26
5
开发者安装方式速度较慢,且专为开发环境设计。因此,您应遵循标准安装说明。自动化安装其实很简单。我的安装服务现已完全自动化(除了 Mailgun 所需的 DNS 设置,因为我无法控制客户端的 DNS)。
安装过程中最困难的部分是邮件配置。
此外,安装和维护是不同的概念。
感谢 @pfaffman !很抱歉造成了混淆,我在原始消息中把两件事搞混了:1) 为 Gitpod 社区安装 Discourse,以及 2) 为 Discourse 开发者和贡献者自动化开发环境设置。我很庆幸自己正在按照开发者指南进行第 2) 项,而不是第 1) 项。
@david 嗯,不幸的是,使用以下命令:
bundle exec rake db:create db:migrate &&
RAILS_ENV=test LOAD_PLUGINS=1 bundle exec rake db:create db:migrate
仍然报错:
== Seed from /workspace/discourse/db/fixtures/990_settings.rb
Discourse 主机名:localhost 不是有效的电子邮件域名!
== Seed from /workspace/discourse/db/fixtures/990_topics.rb
rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "polls" does not exist
LINE 8: WHERE a.attrelid = '"polls"'::regclass
^
我是否正确理解了您的建议?您还有其他解决思路吗?(我之前尝试过先删除这些表,但遇到了另一个我不记得的错误。不过我很乐意再试一次。)
另外,我忘了提到,我的设置说明直到上周左右都还能正常工作,这个错误是在最近一次 Discourse rebase 后出现的。我想这可能与迁移到 Rails 6 有关?DEV: Upgrade Discourse to Rails 6 (#8083) · discourse/discourse@32b8a2c · GitHub
供您参考,您可以通过尝试在 Gitpod 中打开我的 Discourse 分叉来轻松复现此错误:Dashboard 。您将看到我的自动化设置失败,并进入一个交互式环境,您可以在终端中尝试各种 Discourse 命令。
gerhard
(Gerhard Schlager)
2019 年9 月 17 日 15:39
7
@sam 看起来 FIX: Rails 6 multisite migrations and plugin migrations · discourse/discourse@025d4ee · GitHub 这个提交破坏了一些功能。
与提交信息相反,我认为在此提交之前插件迁移是正常工作的。但现在不行了。无论是否提供 LOAD_PLUGINS=1,在我的开发环境中插件迁移都不会运行。
我认为问题出在这里:
--- a/lib/plugin/instance.rb
+++ b/lib/plugin/instance.rb
@@ -516,7 +516,7 @@ class Plugin::Instance
Rake.add_rakelib(File.dirname(path) + "/lib/tasks")
# Automatically include migrations
- migration_paths = Rails.configuration.paths["db/migrate"]
+ migration_paths = ActiveRecord::Migrator.migrations_paths
migration_paths << File.dirname(path) + "/db/migrate"
unless Discourse.skip_post_deployment_migrations?
pfaffman
(Jay Pfaffman)
2019 年9 月 17 日 15:58
8
jankeromnes:
为 Gitpod 社区安装 Discourse,
那就是 INSTALL-cloud 。
想象一下,如果有一个 Docker 容器随 Discourse 一起提供,你无需安装任何内容即可直接使用它。
Developing using Docker
Since Discourse runs in Docker, you should be able to run Discourse directly from your source directory using a Discourse development container.
Pros: No need to install any system dependencies, no configuration needed at all for setting up a development environment quickly.
Cons: Will be slightly slower than the native dev environment on Ubuntu, and much slower than a native install on MacOS.
See also Developing Discourse using a Dev Container …
sam
(Sam Saffron)
2019 年9 月 17 日 21:56
9
我在多站点迁移中遇到了这个错误,在开发/测试数据库中是正常的,今天会仔细调试。
sam
(Sam Saffron)
2019 年9 月 18 日 03:20
11
参考:
committed 03:17AM - 18 Sep 19 UTC
In Rails 6 due to internal changes, the following sequence no longer works:
```…
RAILS_ENV=test bin/rake db:migrate
RAILS_ENV=test bin/rake db:schema:dump
dropdb discourse_test
createdb discourse_test
RAILS_ENV=test bin/rake db:schema:load
RAILS_ENV=test bin/rake db:migrate
```
What appears to be happening is that our tracking of plugin migrations is
being missed on schema:dump or load.
A more comprehensive fix restoring schema:dump / load support will be
investigated.
这应该能让开发环境在遵循指南时表现正常。
@kris.kotlarek 能否看一下这个提交……为什么在 Rails 6 中,我们的插件会导致 schema dump → load 停止工作?
我认为我发现了 ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "polls" does not exist 的问题所在
当在创建数据库时评估 load_config 时,它会覆盖 migrations_paths
因此,当我们尝试同时评估 db:create 和 db:migrate 时会发生以下情况:
然而,如果我们分别运行它们,路径是正常的:
我认为我们有两个选择:
修改指南,建议分别使用两个命令
使用猴子补丁(Monkey patch)并采用 ||=
你怎么看?
sam
(Sam Saffron)
2019 年9 月 18 日 11:13
14
这样能解决吗?
RAILS_ENV=test bin/rake db:migrate
RAILS_ENV=test bin/rake db:schema:dump
dropdb discourse_test
createdb discourse_test
RAILS_ENV=test bin/rake db:schema:load
RAILS_ENV=test bin/rake db:migrate
非常感谢你调查这个 bug!: +1: 我暂时会使用更新后的说明来绕过它。
啊,很有趣,谢谢!我会查看现有的开发用 Dockerfile,看看是否可以通过 Gitpod 一键启动它们。 那会很棒。
有趣的是,将 db:create 和 db:migrate 拆分为两个独立的命令(如 Install Discourse on Ubuntu or Debian for Development - #321 中所建议的)也“奏效”了。
(但现在,执行 DISCOURSE_DEV_HOST=.gitpod.io bundle exec rails s -b 0.0.0.0 似乎陷入了崩溃循环,报错如下:
/workspace/.rvm/gems/activesupport-6.0.0/lib/active_support/dependencies.rb:551:in `load_missing_constant': Unable to autoload constant Version, expected /workspace/discourse/lib/version.rb to define it (LoadError)
同时,Web 服务器再次阻止了我的 Gitpod 预览 URL:
Blocked host: 3000-a8a71720-4c30-466b-aea5-5344c97c4e94.ws-eu0.gitpod.io
)
sam
(Sam Saffron)
2019 年9 月 18 日 21:40
20
你好 Jan,如果你有时间,我很好奇 Spectrum 具体有哪些问题,或者哪些地方没有达到你的预期?
我一直有关注 Spectrum,时不时也会看看关于它的报道。
(我试着给你发私信聊这件事,但不知为何,当我点击你的个人资料时,没有看到发送私信的按钮。)