有什么方法可以为经过身份验证的 rubygems 存储库设置内部未经身份验证的代理吗?

问题描述 投票:0回答:1

我想使用我的私有 GitHub Packages 存储库(例如

https://rubygems.pkg.github.com/myorg
),它需要身份验证作为最终/上游源,但在内部网络上有一个不需要身份验证的代理服务器,并且能够提供服务那些私人包裹。这样做的原因是为了更轻松地构建映像,而无需将凭据传递给 CI 系统或将其烘焙到映像中。

我有 Sonatype Nexus,并设置了代理存储库,但它似乎无法代表我执行身份验证部分。我们在 golang 上也遇到了类似的问题,并找到 Athens 来提供该身份验证; rubygems 有类似的东西吗?

最后,我认为我希望能够设置捆绑器镜像,而无需客户提供凭据。像这样的东西:

$ bundle config mirror.https://rubygems.pkg.github.com/myorg http://nexus.internal.example.com/repository/rubygems
ruby proxy rubygems nexus github-packages
1个回答
0
投票

事实证明,Nexus 存储库的 HTTP 身份验证部分确实有效,并解决了这个问题。我肯定使用了不正确或未经授权的凭据。用户名应该是您的 Github 用户名,密码是具有“read:packages”权限的个人访问令牌(经典)。

设置完成后,有 2 种使用方法:

  1. 直接:

    # Gemfile
    source 'http://nexus.internal.example.com/repository/rubygems' do
      gem 'my_gem_name', '1.0.0'
    end
    
  2. 或者作为“镜子”:

    # In your Gemfile:
    source 'https://rubygems.pkg.github.com/myorg' do
      gem 'my_gem_name', '1.0.0'
    end
    
    
    # Then run the following command:
    $ bundle config mirror.https://rubygems.pkg.github.com/myorg http://nexus.internal.example.com/repository/rubygems
    
    # Optionally, run this to fall-back if Nexus is down:
    $ bundle config mirror.https://rubygems.pkg.github.com/myorg.fallback_timeout 3
    
    
    # A third, but less explicit option is to use an environment variable.
    # Note that everything using the hostname matches, not just sources with the hostname + path.
    # (So everything on GithHub packages, not just your org.)
    # This should only be used if you are unable to run the bundle commands above.
    $ export BUNDLE_MIRROR__RUBYGEMS__PKG__GITHUB__COM='http://nexus.internal.example.com/repository/rubygems'
    
© www.soinside.com 2019 - 2024. All rights reserved.