你好,
我在一台 Ubuntu 服务器上运行标准的自托管 Discourse 安装,使用的是官方的 discourse_docker 设置。
环境
- Ubuntu Server
- Docker
- 官方
discourse_docker - 单容器安装(
app.yml) - 使用以下命令执行重建:
cd /var/discourse
./launcher rebuild app
问题
重建过程在引导(bootstrap)阶段失败,此时 Discourse 尝试从 GitHub 更新应用程序源代码。
失败发生在:
git fetch --tags --prune-tags --prune --force origin
并报错:
fatal: unable to access 'https://github.com/discourse/discourse.git/': SSL connection timeout
随后显示:
FAILED
bootstrap failed with exit code 128
重要发现
可通过 HTTPS 访问 GitHub
在宿主机上:
curl -I https://github.com
可以正常工作。
此外:
curl -I https://raw.githubusercontent.com
也能正常访问。
我的环境中 Git over HTTPS 不可靠
在 Discourse 环境内部:
git ls-remote https://github.com/discourse/discourse.git
失败并报错:
SSL connection timeout
根据我的调查,这似乎是由于我的互联网服务提供商与 GitHub 之间的 HTTPS 连接问题所致。目前我并不打算解决这个网络问题本身,而是希望找到一种使用 SSH 进行 Discourse 重建的方法,因为在当前环境中,通过 SSH 连接 GitHub 是正常工作的。
GitHub SSH 认证已生效
我生成了一个新的 SSH 密钥,将其添加到 GitHub,并验证了认证:
ssh -T git@github.com
返回:
Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.
此外:
git ls-remote git@github.com:discourse/discourse.git
在宿主机上也能成功执行。
仓库 URL
在宿主机上,我已将 /var/discourse 的远程仓库改为使用 SSH:
origin git@github.com:discourse/discourse_docker.git
Git 操作可以正常进行。
然而,在 Discourse 应用容器内部:
cd /var/www/discourse
git remote -v
显示:
origin https://github.com/discourse/discourse.git
因此,在引导阶段,Discourse 仍然尝试使用 HTTPS。
我希望实现的目标
我的主要目标是在 GitHub HTTPS 连接不稳定或频繁超时的环境中,使 Discourse 的重建过程能够可靠运行。
我想了解:
- 是否有官方支持的方法,让 Discourse 的引导和重建过程使用 SSH 而非 HTTPS 连接 GitHub?
- 如果没有,那么在 Git HTTPS 不可靠但 SSH 正常的情况下,推荐的做法是什么?
- 是否有支持的方法,可以在引导/构建阶段注入 SSH 凭证?
- 是否有人成功配置过
discourse_docker,使其通过 SSH 获取 Discourse 源代码更新?
我倾向于寻找一种能够经受未来升级的方案,但我也很想知道在引导阶段基于 SSH 的拉取操作在技术上是否被官方支持。
非常感谢您的任何指导。
谢谢。