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

FR: Run Bazel actions inside a container #132

Closed
ding-ma opened this issue Mar 29, 2023 · 9 comments
Closed

FR: Run Bazel actions inside a container #132

ding-ma opened this issue Mar 29, 2023 · 9 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request need: discussion Needs a proper discussion around the problem.

Comments

@ding-ma
Copy link

ding-ma commented Mar 29, 2023

Similar feature to container_run_and_commit in rules_docker

See

@thesayyn
Copy link
Collaborator

fundamentally this is a bad idea. see why: #35 (comment)

@alexeagle alexeagle changed the title FR: oci_run_and_commit FR: Run Bazel actions inside a container Mar 29, 2023
@alexeagle
Copy link
Collaborator

alexeagle commented Mar 29, 2023

I think it's possible that there's a better way to containerize actions, we should give it some thought. But as we wrote in the main README, the goal here is to prevent unmaintainable design mistakes that we learned from rules_docker.

Also Bazel has its own way of providing isolation for build actions, so it's not clear to me why we would implement another one in rules_oci. I'd like to see some experiments with --experimental_enable_docker_sandbox which allows you to just use strategy=docker. (and --experimental_docker_image allows you to pick the image for the containerized action)

@thesayyn
Copy link
Collaborator

I dug a bit into what can be done; this looks possible with the docker strategy. with the https://github.com/GoogleContainerTools/kaniko combination, it should work

@ding-ma
Copy link
Author

ding-ma commented Apr 13, 2023

I'll experiment with --experimental_docker_image and report back findings.

@alexeagle
Copy link
Collaborator

I think we should slip this from 1.0 already, since we'd like to get an RC out this week, and it's still a science project.

@alexeagle alexeagle removed this from the 1.0 milestone Apr 17, 2023
@alexeagle alexeagle pinned this issue Aug 15, 2023
@aw185176
Copy link
Contributor

aw185176 commented Oct 4, 2023

Also Bazel has its own way of providing isolation for build actions, so it's not clear to me why we would implement another one in rules_oci

One use case is pre-generating a .bazelrc for remote caching that has a cache key prefix based on the system dependencies that aren't tracked by Bazel. Such a task needs to be ran in the container to be accurate. I do agree that generally speaking such a thing should not really be necessary.

@alexeagle
Copy link
Collaborator

@aw185176 I don't think that sounds like a containerization task. If you want Bazel flags to be dynamic based on the system, then a /tools/bazel wrapper is the way to set those flags.

@aw185176
Copy link
Contributor

aw185176 commented Oct 5, 2023

@aw185176 I don't think that sounds like a containerization task. If you want Bazel flags to be dynamic based on the system, then a /tools/bazel wrapper is the way to set those flags.

With that approach you then need to sync said tools/bazel wrapper to each Bazel repo using the same caching infrastructure. The approach I outlined is based on what the K8s project was doing at one point. My understanding is that it has become somewhat common / recommended outside of that project (eg https://forum.buildkite.community/t/any-experience-setting-up-a-shared-remote-build-cache-using-bazel/1119/4). I wouldn't necessarily recommend it and we are likely to move away from the approach internally when possible, I only wanted to highlight that it is a real thing that real teams do today.

@thesayyn thesayyn added documentation Improvements or additions to documentation enhancement New feature or request need: discussion Needs a proper discussion around the problem. labels Dec 12, 2023
@thesayyn
Copy link
Collaborator

Closing as completed #570

@thesayyn thesayyn unpinned this issue May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request need: discussion Needs a proper discussion around the problem.
Projects
None yet
Development

No branches or pull requests

4 participants