【问题标题】:bazel and docker images: what's the point of @go_image_base//image?bazel 和 docker 图像:@go_image_base//image 的意义何在?
【发布时间】:2019-12-02 07:00:00
【问题描述】:

我有一个 src/BUILD.bazel(在 MacO 上):

load("@io_bazel_rules_docker//go:image.bzl", "go_image")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
load("@io_bazel_rules_docker//container:container.bzl", "container_image")

go_image(
    name = "bazel_docker_image",
    srcs = ["main.go"],
    pure = "on",
)

没有错误的作品:

bazel build //src:bazel_docker_image

显示:

INFO: Analyzed target //src:bazel_docker_image (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //src:bazel_docker_image up-to-date:
    bazel-bin/src/bazel_docker_image-layer.tar
INFO: Elapsed time: 2.361s, Critical Path: 0.03s
INFO: 0 processes.
INFO: Build completed successfully, 1 total action

但 tar 文件(可以作为图像导入 docker)仅包含 仅静态链接的任务。该图像不能作为容器运行,因为该图像不包含,除其他外,

/usr/lib/libSystem.B.dylib

那么@go_image_base//image 的意义何在?我认为这应该制作一个包含所有必需库、有效入口点等的基本完整的独立映像。

如果在 bazel-bin/external/go_image_static/image/000.tar.gz.nogz 中查看,看起来 Bazel 有一个完整的图像,更像是 Bazel 文档所建议的输出。是什么赋予了?

此外,Bazel 文档还提到:

To address this, we publish variants of the distroless runtime images
tagged :debug, which are the exact-same images, but with additions
such as busybox to make debugging easier.

但没有提供示例。

在这一点上,我最好从 alpine 制作容器映像并自己做所有事情。我真的很想解决这个问题,因为 Bazel 通常确实让这个 docker 的东西更容易。

【问题讨论】:

    标签: docker bazel


    【解决方案1】:

    这个问题正在回答(希望能解决)here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-02
      • 2021-08-04
      • 2022-11-12
      • 2020-05-20
      • 1970-01-01
      相关资源
      最近更新 更多