【发布时间】:2020-09-26 07:38:36
【问题描述】:
应用结构(Python FastAPI):
-my_app
-server.py
-Procfile
-requirements.txt
为了安装我的 Heroku 应用所需的私有 git 存储库,我在requirements.txt 中添加了以下行:
git+https://<github-token>@github.com/me/my-private-repo.git
然而,在推送时,Github 给我发邮件说,由于我在提交中暴露了我的令牌,它已经撤销了令牌。 (我的应用程序仓库是私有的。)完全公平!但是,我的 Heroku 构建现在失败了,因为它在尝试安装私有存储库时提示输入密码。
我已经多次搜索 SO/互联网:私人回购,但总是遇到相互矛盾的建议。
很高兴听到在这种情况下的最佳做法是在自动构建中安全地安装私有存储库。
到目前为止我已经尝试过:
-
git+git://username:password@github.com/me/myrepo.git而不是 token 显然有同样的问题 -
git+ssh://git@github.com/me/myrepo.git- 产生错误Host key verification failed. - 将用户名:密码(或令牌)存储为 Heroku 环境变量 - 从 here 看来,
pip不可能做到这一点
要扩展 ssh 选项,请在我的本地计算机上执行以下操作:
pip3 install git+ssh://git@github.com/me/my_private-repo.gitgit clone https://github.com/me/my_private-repo.git
但是,当我的 requirements.txt 包含 git+ssh://git@github.com/me/my_private-repo.git 时,我的 Heroku 构建返回 Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
【问题讨论】:
-
您尝试了哪些相互矛盾的建议,为什么它们不能让您满意?
-
扩大了问题以包括这个
-
Host key verification failed.可以是easily fixed:ssh-keygen -R github.com; ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts。 stackoverflow.com/…