I am looking for a way to build docker images based on the outputs of other rules. In our case, we have some java_binary and python_binary rules that we want to put in a docker image, so we can then use the images to deploy our stack.
As much as I saw, with a simple rule, you can put outputs of another rule into the docker image. Here is a minimal example of what my package looks like:
load("@bazel_tools//tools/build_defs/docker:docker.bzl", "docker_build")
py_binary(
name = "foo",
srcs = ["foo.py"], # Hello world script
)
docker_build(
name = "server_docker",
files = [":foo"],
base = "@docker_python3//:image", # a docker_pull rule
entrypoint = ["python3", "./foo"],
)
The generated foo binary is put in the docker image, however its runfiles are not:
AssertionError: Cannot find .runfiles directory for ./foo
By changing the entrypoint to ["/bin/ls"], here is the result:
bin etc foo.py lib mnt root sbin sys usr
dev foo home media proc run srv tmp var
Am I misusing the docker_build rule or is it unsupported right now?
Regards,
--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/9da07e50-3ba5-4919-b215-19c5176cf79d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Is there a more generic way to include runfiles, so we can also include our java/scala .jar dependencies in the docker image? By including only the :rule.jar, we miss all dependencies.