安装 gem https 而不是 git

Install gem https instead of git

我有一个 Gemfile,其中包含一个私有存储库

gem 'private', git: 'git@github.com:user/private.git', branch: 'master'

我想通过 https 安装依赖项。为此,我这样做

ENV BUNDLE_GITHUB__COM="$GITHUB_ACCESS_TOKEN:x-oauth-basic"
RUN git config --global url."https://github.com/".insteadOf git@github.com:

之后 bundle install 仍然需要登录名和密码。我究竟做错了什么? 我检查过,容器有正确的令牌

/app # bundle install
Fetching git@github.com:user/private.git
Username for 'https://github.com':

我用https授权解决不了问题,只好把ssh扔到容器里。 我这样做了: 在 Dockerfile

RUN --mount=type=ssh,id=ssh-key bundle install

构建图像

DOCKER_BUILDKIT=1 docker build --ssh ssh-key=./my-key -t ...