在隔离的 CentOS 7 服务器上安装 Discourse

Most plugins carry all the code they need and have a simple install. Those two you tried to use need to fetch gems (libraries) from the internet to able to function.

3 个赞

do you know where in the code those ruby gem fetches for plugins happen? I tried looking for it but haven’t found the right place yet.

I’m thinking maybe instead of using cached gems maybe it would be more elegant to run a rubygems mirror on the isolated host, i found a tutorial here and it looks like you can configure extra system-wide gem sources

https://guides.rubygems.org/run-your-own-gem-server/

1 个赞

我们内部的 Discourse 系统一直愉快地运行着同一个旧版本,但既然我们终于要淘汰 IE9 了,升级已是刻不容缓。
我可以确认,本指南对于最新版本的 Discourse 依然适用。即使使用的是 RHEL 8 而非 RHEL 7 也没问题:slight_smile

在实验过程中,我找到了一种方法,让 discourse-prometheus 和 discourse-calendar 插件即使在离线环境下也能运行,即便存在额外的依赖项。诀窍是从构建服务器的插件目录以及 /var/www/discourse/vendor/bundle/ruby 中提取 Ruby gems:

docker run -it -v ~/local/rubygems.org:/local-rubygems local_discourse/app /bin/bash -c "cp -rv /var/www/discourse/vendor/bundle/ruby /local-rubygems"
docker run -it -v ~/local/rubygems.org/plugin-gems/discourse-calendar:/local-rubygems local_discourse/app /bin/bash -c "cp -rv /var/www/discourse/plugins/discourse-calendar/gems /local-rubygems"
docker run -it -v ~/local/rubygems.org/plugin-gems/discourse-prometheus:/local-rubygems local_discourse/app /bin/bash -c "cp -rv /var/www/discourse/plugins/discourse-prometheus/gems /local-rubygems"

然后在 /templates/web.template.yml 中:

  - exec:
      cd: $home
      hook: bundle_exec
      cmd:
        # 复制本地 Ruby 缓存
        - cp -rv /local-rubygems.org/ruby/* $home/vendor/bundle/ruby/
        - cp -rv /local-rubygems.org/plugin-gems/* $home/plugins/
        - su discourse -c 'bundle install --local --deployment --retry 3 --jobs 4 --verbose --without test development'

顺便提一下,关于 Active Directory IIS SSO 的主题似乎在某处丢失了,但代码仍然可在 GitHub - laktak/discourse-sso: Single Sign On for Discourse with Active Directory · GitHub 获取,并且仍然适用于现已更名为 DiscourseConnect SSO 的系统。

我尝试了另一次升级,看起来在某个时候 web.template.yml 中添加了一个新的“yarn install”部分,这在隔离环境中会中断。

- exec:
      cd: $home
      cmd:
        - "[ ! -d 'node_modules' ] || su discourse -c 'yarn install --production && yarn cache list'"

比较新旧容器的内容时,看起来新容器的 /usr/local/share/.cache/yarn/v6 中有很多缓存的 yarn 包,而旧容器中则没有,我猜所有必需的 node.js 以前都包含在基础镜像中,但现在它们在重建过程中被更新了?

我将尝试以与复制 ruby 缓存相同的方式复制 yarn 缓存,看看是否能让 yarn 使用构建框中的缓存包。