Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel: support tar driver for oci_image #461

Open
blackliner opened this issue Jul 24, 2024 · 2 comments
Open

Bazel: support tar driver for oci_image #461

blackliner opened this issue Jul 24, 2024 · 2 comments

Comments

@blackliner
Copy link

blackliner commented Jul 24, 2024

Not sure if this is a bug or FR, but the documentation is at least a tiny bit contradicting. From the docu, I would expect that the only limitation I get when using the tar driver is the missing support for commandTests. See this section:

tar: a tar driver, which extracts an image filesystem to wherever tests are running, and runs file/metadata tests against it. Does not support command tests.

The example in that same section shows how it works providing a image:tag (not a *.tar file!)

container-structure-test test --driver tar --image gcr.io/registry/image:latest --config config.yaml

When using the tar driver in bazel

oci_image(
    name = "job_list_image",
    base = "@python_base",
    cmd = ["/job_list"],
    tars = [":job_list_tar"],
    workdir = "/job_list.runfiles/_main",  # workaround for https://github.com/bazelbuild/rules_pkg/issues/813
)

container_structure_test(
    name = "job_list_image_test",
    size = "small",
    configs = ["job_list_image_test.yaml"],
    driver = "tar",
    image = ":job_list_image",
)

it fails with Error in fail: when the 'driver' attribute is not 'docker', then the image must be a .tar file SOURCE

So is this a real limitation? The tool itself apparently is happy to consume image:tag combos 🤔

If so, what is the canonical way to use the tar driver with rules_oci?

@blackliner
Copy link
Author

blackliner commented Jul 24, 2024

Workaround: use oci_tarball. I thought this rule is only used as a bazel run target to load the tarball into your docker daemon, but it turns out to also provide a tarball 🎉

oci_image(
    name = "job_list_image",
    base = "@python_base",
    cmd = ["/job_list"],
    tars = [":job_list_tar"],
    workdir = "/job_list.runfiles/_main",  # workaround for https://github.com/bazelbuild/rules_pkg/issues/813
)

oci_tarball(
    name = "job_list_image_tar",
    image = ":job_list_image",
    repo_tags = ["job_list:local-dev"],
)

container_structure_test(
    name = "job_list_image_test",
    size = "small",
    configs = ["job_list_image_test.yaml"],
    driver = "tar",
    image = ":job_list_image",
)

@blackliner
Copy link
Author

blackliner commented Jul 25, 2024

I think it boils down to OCI layouts not being supported 🤔

related feature request: #305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant