rules_docker icon indicating copy to clipboard operation
rules_docker copied to clipboard

Using distroless as layer for `container_image`

Open aryeh-looker opened this issue 3 years ago • 2 comments

Is this supported?

# WORKSPACE
container_pull(
    name = "envoyproxy-distroless",
    digest = "sha256:319ae2f7889c0ca395da53ca835e04aa09fe2bff23f4fab962853b9d68129bf2",  # v1.22-latest
    registry = "index.docker.io",
    repository = "envoyproxy/envoy-distroless",
)

container_pull(
    name = "openjdk",
    digest = "sha256:e81b7f317654b0f26d3993e014b04bcb29250339b11b9de41e130feecd4cd43c",  # 11
    registry = "index.docker.io",
    repository = "openjdk",
)
# BUILD
load("@io_bazel_rules_docker//container:container.bzl", "container_image")

container_image(
    name = "image",
    base = "@openjdk//image",
    layers = [
        "@envoyproxy-distroless//image",
    ],
)

Error:

Analyzing: target //docker/uber-image:image (1 packages loaded, 0 targets configured)
ERROR: /usr/local/google/home/aryehh/Development/code/docker/uber-image/BUILD.bazel:3:16: in layers attribute of container_image_ rule //docker/uber-image:image: '@envoyproxy-distroless//image:image' does not have mandatory providers: 'LayerInfo'. Since this rule was created by the macro 'container_image', the error might have been caused by the macro implementation
ERROR: /usr/local/google/home/aryehh/Development/code/docker/uber-image/BUILD.bazel:3:16: Analysis of target '//docker/uber-image:image' failed
ERROR: Analysis of target '//docker/uber-image:image' failed; build aborted: 
INFO: Elapsed time: 0.312s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)

Any guidance?

aryeh-looker avatar Aug 10 '22 23:08 aryeh-looker

Have also tried this, which fails:

load("@io_bazel_rules_docker//container:container.bzl", "container_image")

container_image(
    name = "envoy",
    base = "@envoyproxy-distroless//image",
)

container_image(
    name = "image",
    base = "@openjdk//image",
    layers = [
        ":envoy",
    ],
)

aryeh-looker avatar Aug 10 '22 23:08 aryeh-looker

Have also tried this, which succeeds, but within which I cannot find the envoy binary:

container_image(
    name = "envoy",
    base = "@envoyproxy-distroless//image",
)

container_image(
    name = "image",
    base = "@openjdk//image",
    tars = [
        ":envoy-layer.tar",
    ],
)
 % docker run --rm -it --entrypoint bash bazel/docker/uber-image:image
root@8f7aae820b9c:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@8f7aae820b9c:/# find . -name "*envoy*"
root@8f7aae820b9c:/# find . -iname "*envoy*"

aryeh-looker avatar Aug 10 '22 23:08 aryeh-looker

This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_docker!

github-actions[bot] avatar Feb 07 '23 02:02 github-actions[bot]

This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

github-actions[bot] avatar Mar 09 '23 02:03 github-actions[bot]