简体   繁体   English

如何配置 rebar3 以从另一台主机获取依赖项?

[英]How to configure rebar3 to fetch dependencies from another host?

I have an app which uses rebar3, eg cowboy.我有一个使用 rebar3 的应用程序,例如牛仔。 My question is: how can I easily configure it to fetch cowboy from another host?我的问题是:如何轻松配置它以从另一台主机获取牛仔? That is I want to point it from github to another host.那就是我想将它从 github 指向另一个主机。

By default, rebar3 will only grab packages from either hex.pm, any git repository, or any mercurial repository.默认情况下, rebar3只会从 hex.pm、任何 git 存储库或任何 mercurial 存储库中获取包。 You can see your options here .您可以在此处查看您的选择。

If these defaults are not enough for you, you can create your own dependency resources .如果这些默认值对您来说还不够,您可以创建自己的依赖资源 This will require you to write some Erlang code in order to tell rebar3 how to find and download the package(s) you are trying to use.这将需要您编写一些 Erlang 代码,以告诉rebar3如何查找和下载您尝试使用的包。

You want to build cowboy that has two dependencies which are git repositories on GitHub ( https://github.com/ninenines/cowlib and https://github.com/ninenines/ranch to be specific). You want to build cowboy that has two dependencies which are git repositories on GitHub ( https://github.com/ninenines/cowlib and https://github.com/ninenines/ranch to be specific). But you want to fetch the repositories from some other host, like your company's own git server where you mirrored all public repositories you need.但是您想从其他一些主机获取存储库,例如您公司自己的 git 服务器,您在其中镜像了您需要的所有公共存储库。

You have a number of options:您有多种选择:

  • Fork cowboy and change the dependency URL-s in the rebar.config . Fork cowboy 并更改rebar.config中的依赖 URL-s。 This is the only (sane) way I know to make Rebar3 fetch the dependencies from a different location.这是我知道让Rebar3从不同位置获取依赖项的唯一(理智)方法。 The other options will target the layers below Rebar3 to achieve the same result.其他选项将针对Rebar3 下方的图层以实现相同的结果。
  • Configure git to rewrite GitHub URL-s to URL-s on your server, following eg https://stackoverflow.com/a/11383587/9015322配置 git 以将 GitHub URL-s 重写为服务器上的 URL-s,例如https://stackoverflow.com/a/11383587/990
git config --global url.https://git.mycompany.com/.insteadOf https://github.com/
  • Add an /etc/hosts entry that resolves github.com to the IP of your server.将解析 github.com 的/etc/hosts条目添加到服务器的 IP。 You'll probably have to create a fake self-signed certificate for github.com, and make git on the build machine trust it.您可能必须为 github.com 创建一个虚假的自签名证书,并让构建机器上的 git 信任它。 But you can do that following the advice here: https://stackoverflow.com/a/16543283/9015322但是您可以按照此处的建议进行操作: https://stackoverflow.com/a/16543283/9015322

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM