本指南假设您已进行自托管标准安装 。我们_仅_在此处支持标准的安装方法,因此这些说明假定您具有标准安装。
本指南仅适用于自托管的 Discourse 实例 。如果您使用的是托管服务,可用插件由您的托管服务提供商控制。例如,在我们的托管服务上,这些特定插件 根据托管级别提供。
在本教程中,我们将安装 Discourse Solved 插件。
本教程要求了解如何使用 GitHub 仓库,特别是如何获取或复制 git clone URL 以及如何使用 nano 通过终端编辑 YAML (*.yml) 文件,特别是如何在 nano 中保存和退出 。YAML 文件非常依赖缩进,因此在复制、粘贴和编辑 Discourse 实例所需的 *.yml 文件时,请务必注意这一点。始终在 .yml 文件中使用空格进行缩进,不要使用制表符。
复制插件的 GitHub git clone url。
访问容器的 app.yml 文件(位于 /var/discourse/containers/):
cd /var/discourse
nano containers/app.yml
将插件的仓库 URL 添加到容器的 app.yml 文件中:
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git
- sudo -E -u discourse git clone https://github.com/discourse/discourse-solved.git
将插件的 git clone url 添加到包含 git clone https://github.com/discourse/docker_manager.git 的行的正下方)
遵循 docker_manager.git 行的现有格式;如果它不包含 sudo -E -u discourse,则插入 - git clone https://github.com/discourse/discourse-solved.git。
重新构建容器:
cd /var/discourse
./launcher rebuild app
这样,您已成功在 Discourse 实例上安装了 Discourse Solved 插件!
如果您的插件托管在私有仓库中
您必须使用 OAuth 令牌:
使用 OAuth 令牌,您可以通过与公共仓库相同的方式安装插件,并且不需要创建 SSH 密钥。
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- sudo -E -u discourse git clone https://<token>@github.com/owner/repo.git
我们强烈建议您对私有仓库中的插件使用 OAuth 令牌。但是,如果您无法使用,请参阅下文。
SSH 密钥私有安装步骤
run:
- exec: echo "Beginning of custom commands"
- exec: cd /var/www/discourse && sudo -u discourse bundle install --deployment --without test --without development
- exec: echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /user/.ssh/config
- file:
path: /user/.ssh/id_rsa
chmod: 600
contents: |
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEArCQG213utzqE5YVjTVF5exGRCkE9OuM7LCp/FOuPdoHrFUXk
.... etc ....
-----END RSA PRIVATE KEY-----
- file:
path: /user/.ssh/id_rsa.pub
chmod: 600
contents: ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tj .... etc .... user@discourse
- exec: cd $home/plugins && git clone git@github.com:SecretOrg/secret-plugin.git
- exec: cd $home && sudo -E -u discourse bundle exec rake db:migrate
- exec: cd $home && rm -fr tmp/cache
- exec: cd $home && sudo -E -u discourse bundle exec rake assets:precompile
- exec: rm /user/.ssh/id_rsa
- exec: rm /user/.ssh/id_rsa.pub
- exec: echo "End of custom commands"
cd /var/discourse
./launcher rebuild app
您的私有插件应该已安装在您的 Discourse 实例上。
如何卸载插件
要删除插件,只需从 app.yml 文件中删除 - git clone https://github.com/... 行,然后通过以下命令重建您的站点:
cd /var/discourse
./launcher rebuild app
173 个赞
我已更新指南,使用另一个示例插件替换 Discourse Spoiler Alert,该插件已捆绑到核心中。
我使用了 Discourse Solved ,但如果使用其他插件效果更好,请告诉我。
9 个赞
我在 Digital Ocean 上托管了 discourse,当我使用该格式时,它显示了此错误。
FAILED
--------------------
Pups::ExecError: cd /var/www/discourse/plugins && sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git - sudo -E -u discourse git clone https://github.com/discourse/discourse-solved.git failed with return #<Process::Status: pid 252 exit 129>
Location of failure: /usr/local/lib/ruby/gems/3.2.0/gems/pups-1.2.1/lib/pups/exec_command.rb:132:in `spawn'
exec failed with the params {"cd"=>"$home/plugins", "cmd"=>["sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git - sudo -E -u discourse git clone https://github.com/discourse/discourse-solved.git"]}
bootstrap failed with exit code 129
** 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.
2a49220a4ff35feac3c1a9a4a9c1cad1094bde4c9ba321975ebc9ae7ead2bbee
然后我使用了此格式
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git && sudo -E -u discourse git clone https://github.com/discourse/discourse-solved.git
而不是
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- sudo -E -u discourse git clone https://github.com/discourse/docker_manager.git
- sudo -E -u discourse git clone https://github.com/discourse/discourse-solved.git
4 个赞
wal
2024 年8 月 13 日 04:21
339
抱歉问了一个愚蠢的问题,但我该如何知道是否需要为 git clone 语句包含 sudo -E -u discourse?
3 个赞
Moin
2024 年8 月 18 日 05:59
340
你的 docker_manager 行看起来是怎样的?
Discourse:
遵循 docker_manager.git 行的现有格式;如果它不包含 sudo -E -u discourse,则插入 - git clone https://github.com/discourse/discourse-solved.git。
4 个赞
wal
2024 年8 月 19 日 12:40
341
我的 app.yml 中的其他条目都没有 sudo 部分,所以我省略了它,到目前为止一切正常。
5 个赞
Discourse:
修改 app.yml 文件,如以下示例所示:
- exec: echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /user/.ssh/config
看起来这种方法不再有效了。
sh: 1: cannot create /user/.ssh/config: Directory nonexistent
对于我自托管的 GIT 存储库,我真的很想使用 SSH 密钥。
3 个赞
抱歉,我不太明白。
我的仓库可以通过 SSH 访问。如何在没有 SSH 密钥的情况下克隆插件?
1 个赞
pfaffman
(Jay Pfaffman)
2024 年8 月 27 日 22:35
345
哦。也许我错了。那么也许你需要创建那个具有正确权限的目录。m
1 个赞
令人困惑的是,示例中的部分命令需要以 root 用户身份运行,部分则需要以 discourse 用户身份运行。这似乎不太一致。
- exec: cd $home/plugins && git clone git@github.com:SecretOrg/secret-plugin.git
与此相对的是
- exec: cd $home && sudo -E -u discourse bundle exec rake db:migrate
我将在运行容器的 shell 中进行一些挖掘。
nwnuyhs
(Yang Hongsheng)
2024 年9 月 2 日 07:40
347
这个插件安装有点复杂。如果能和安装主题一样简单就好了。
2 个赞
pfaffman
(Jay Pfaffman)
2024 年9 月 2 日 10:34
348
Dashboard.literatecomputing.com 将通过几次点击安装插件。您可以通过加入免费试用组来免费使用它。
4 个赞
Discourse:
SSH 密钥私有安装步骤
@Discourse ,如果您想更新指南,这是可行的代码:
要使用您自己的 SSH 密钥访问私有存储库,请按照以下步骤操作:
将私有 SSH 密钥放在 /var/discourse/shared/standalone/identity/id_rsa(或容器可访问的其他位置;如果您选择其他位置,请记住在下面的模板中相应地更新路径)。
使用以下模板添加您的插件:
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
# 设置私有存储库访问
- chown $(whoami) /shared/identity/id_rsa && chmod 600 /shared/identity/id_rsa
- git config --global core.sshCommand "ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i /shared/identity/id_rsa"
# 我的私有插件
- git clone git@example.com:repo/private-discourse-plugin.git
# 取消设置访问
- git config --global --unset core.sshCommand
5 个赞
Jagster
(Jakke Flemming)
2024 年9 月 2 日 17:36
351
感谢您提供的内容,但我不需要这个,我习惯使用简单的原始版本。
您想解释一下为什么我们应该使用您的示例吗?是因为这个原因吗:
使用您自己的 SSH 密钥来访问私有存储库
1 个赞
Jay Pfaffman:
将通过几次点击安装插件
您好!听起来很棒!但我不知道加入免费试用组后该如何进行!请问,@pfaffman ,您能帮帮我吗?我想安装 SAML 插件。如果能测试 Literate Computing 来安装和运行它,那就太好了!
谢谢!
2 个赞
Robert:
为什么不直接在 URL 中使用令牌?
我的模板片段适用于您除了 SSH 密钥之外没有其他任何方式可以访问 Git 存储库(例如,对于自托管的、位于 SSH 后面的 Git 存储库)。
5 个赞