1

我想在企业网络上使用 Earthly,该网络使用 SSL 探测来颁发自签名证书。我有自定义的 ca-cert pem 文件,我已经成功地将其与 python、curl 等其他工具和工具链一起使用。

我无法用地球来配置它。文档说这可以在地球上的配置中完成$HOME/.earthly/config.yml,所以我跟着它,我的配置文件看起来像

global:
  buildkit_additional_args:
    - "-v"
    - "/Users/maca/.config/corporate/cert/cacerts"

无论我尝试什么,我都会收到此错误

    ongoing |
            internal | --> GIT CLONE https://github.com/earthly/hello-world.git
            internal | --> docker-image://docker.io/alpine/git:v2.30.1
            internal | [          ] resolve docker.io/alpine/git:v2.30.1 ... 0%
            internal | fatal: unable to access 'https://github.com/earthly/hello-world.git/': SSL certificate problem: self signed certificate in certificate chain
            internal | WARN: (GIT CLONE https://github.com/earthly/hello-world.git) error fetching default branch for repository https://github.com/earthly/hello-world.git: exit status 128
            internal | Completed in 121.889053ms
            internal | WARN: Canceled
            internal | Completed in 122.010694ms
            internal | [██████████] resolve docker.io/alpine/git:v2.30.1 ... 100%
Summary of timing information
Note that the times do not include the expansion of commands like BUILD, FROM, COPY (artifact).
            internal | () 243.899747ms
===============================================================
Total           243.899747ms
Total (real)    1m15.652038067s
Error stack trace:
github.com/moby/buildkit/util/stack.Enable
    github.com/moby/buildkit@v0.8.2-0.20210129065303-6b9ea0c202cf/util/stack/stack.go:77
github.com/moby/buildkit/util/grpcerrors.FromGRPC
    github.com/moby/buildkit@v0.8.2-0.20210129065303-6b9ea0c202cf/util/grpcerrors/grpcerrors.go:188
github.com/moby/buildkit/util/grpcerrors.UnaryClientInterceptor
    github.com/moby/buildkit@v0.8.2-0.20210129065303-6b9ea0c202cf/util/grpcerrors/intercept.go:41
google.golang.org/grpc.(*ClientConn).Invoke
    google.golang.org/grpc@v1.38.0/call.go:35
github.com/moby/buildkit/api/services/control.(*controlClient).Solve
    github.com/moby/buildkit@v0.8.2-0.20210129065303-6b9ea0c202cf/api/services/control/control.pb.go:1321
github.com/moby/buildkit/client.(*Client).solve.func2
    github.com/moby/buildkit@v0.8.2-0.20210129065303-6b9ea0c202cf/client/solve.go:215
golang.org/x/sync/errgroup.(*Group).Go.func1
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57
runtime.goexit
    runtime/asm_amd64.s:1371

似乎 Earthly 忽略了我的 cacerts 文件。有谁知道如何解决这个问题?

4

1 回答 1

1

您需要做的不仅仅是挂载 certs 目录;Buildkit 不会接收它们。要为注册表指定自定义证书,您链接的文档详细说明了如何将自定义自签名证书与单个 Docker 注册表一起使用,而不是在整个构建中更一般的情况下。如果您需要使用自定义证书从注册表推送或拉取,您可以使用这些文档。buildkit_additional_config如果需要根据您的情况进行配置,请不要忘记附加配置。

现在,关于为什么+hello-world会失败。该GIT CLONE命令git在后台使用。虽然git在您的本地机器上可能配置为使用这些自定义证书,但git这里的内部构建是不同的,并且不共享相同的证书配置。您需要通过 a 手动引入证书,或COPY使用--secret//使其可访问,具体取决于您的用例。--secret-file--build-arg

我们的单元测试中有一些例子涵盖了这个用例。这是使用自定义证书在 HTTPS 上使用自定义克隆的一个这就是我们如何将自定义证书添加到 build中。

于 2021-10-21T22:44:39.417 回答