气隙网络的依存存档 [英] Dependency archiving for airgapped network

查看:79
本文介绍了气隙网络的依存存档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在未连接到Internet的网络中使用 Bazel .即使不使用任何特殊的库,Bazel仍然需要通过HTTP下载一些依赖项.

I am trying to use Bazel in a network which is not connected to the internet. Even without using any special libraries, Bazel still needs to download some dependencies via HTTP.

建议我尝试设置HTTP代理服务器,该服务器将缓存Bazel下载的文件,然后将代理服务器及其缓存传输到我们隔离的网络中.

I was advised to try and set up an HTTP proxy server which will cache the files which Bazel downloads, and then transfer the proxy server along with its cache into our isolated network.

为了使其正常工作,我需要能够以两种模式操作代理:

In order for this to work, I need to be able to operate the proxy in two modes:

  1. 创建缓存时,代理会缓存来自Bazel的所有请求,并且永远不会丢弃任何文件.
  2. 在网络中使用缓存时,代理从不尝试缓存任何其他文件,在缓存中提供现有文件,也从不丢弃它们.

我查看了nginx来实现此目的,但是找不到任何防止缓存中的文件被丢弃的选项.

I looked at nginx in order to achieve this, but could not find any option to prevent files in the cache from being discarded.

在Nginx中有什么方法可以做到这一点吗?如果没有代理,该代理适合我的用例吗?也许还有我没有考虑过的另一种替代解决方案?

Is there any way to do this in nginx? If not is there a proxy which suites my use case? Or maybe there's another alternative solution which I haven't considered?

推荐答案

您可以使用

You can use the --distdir distribution directory in your airgapped environment. This distribution directory should contain the implicit dependencies of the Bazel binary you're invoking.

要在气密环境之外构建这些依赖关系,请首先以正确的版本签出Bazel源代码树:

To build these dependencies outside of your airgapped environment, first checkout the Bazel source tree at the right version:

git clone https://github.com/bazelbuild/bazel "$BAZEL_DIR"
cd "$BAZEL_DIR"
git checkout "$BAZEL_VERSION"

然后,构建包含该特定Bazel版本的隐式运行时依赖项的tarball:

Then, build the tarball containing the implicit runtime dependencies for that specific Bazel version:

bazel build @additional_distfiles//:archives.tar

将此压缩包导出到一个目录,该目录可以复制到您的空白环境中.注意-strip-components 标志,因为-distdir 在目录嵌套级别上可能很挑剔:

Export this tarball to a directory that can be copied into your airgapped environment. Note the --strip-components flag, because --distdir can be quite finicky with the directory nesting level:

tar xvf bazel-bin/external/additional_distfiles/archives.tar -C "$NEW_DIRECTORY" --strip-components=3

最后,当您在空白环境中使用Bazel时,传递指向该目录的-distdir 标志.我建议将其添加为 .bazelrc 条目:

Finally, when you use Bazel in your airgapped environment, pass the --distdir flag pointing to the directory. I suggest adding it as an .bazelrc entry:

build --distdir=path/to/directory

这篇关于气隙网络的依存存档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆