chainguard-dev/rules_apko

Feature request - Support overlays

Opened this issue · 1 comments

Looking at this example: https://github.com/chainguard-dev/apko/blob/main/examples/overlay.yaml

This doesn't work with bazel because the base yamls are not included in the build. Given something like this:

# apko.yaml
include: base/base.yaml

contents:
  packages:
    - python3
apko_image(
    name = "py_base",
    architecture = select({
        "@platforms//cpu:arm64": "arm64",
        "@platforms//cpu:x86_64": "amd64",
    }),
    config = "apko.yaml",
    contents = "@apko_py_base//:contents",
    tag = "wolfi:latest",
)

Fails to build with:

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
:information_source:            | loading config file: /py_base/apko.yaml
:information_source:            | including base/base.yaml for configuration
⚠            | remote configurations are an experimental feature and subject to change.
Error: failed to load image configuration: failed to read include file: unable to fetch remote include from git: failed to clone /base/base.yaml: Get "https://bazel/apko/base_images/info/refs?service=git-upload-pack": dial tcp: lookup bazel on 172.17.0.1:53: no such host
2024/02/27 13:59:31 error during command execution: failed to load image configuration: failed to read include file: unable to fetch remote include from git: failed to clone /base/base.yaml: Get "https://bazel/apko/base_images/info/refs?service=git-upload-pack": dial tcp: lookup bazel on 172.17.0.1:53: no such host
Target //py_base:py_base failed to build
Use --verbose_failures to see the command lines of failed build steps.

Sounds like we should be able to provide deps to the build like:

apko_image(
    name = "py_base",
    architecture = select({
        "@platforms//cpu:arm64": "arm64",
        "@platforms//cpu:x86_64": "amd64",
    }),
    config = "apko.yaml",
    deps = ["//base:base.yaml"],
    contents = "@apko_py_base//:contents",
    tag = "wolfi:latest",
)

Should be fixed by #64