See https://github.com/bazelbuild/bazel/issues/2176
This is still happening and has now gotten weirder: https://github.com/bazelbuild/bazel/issues/2176#issuecomment-364352176
It would be good for container_image's files to not just be the basename files including in the directory, but to, by default, maintain the full relative file paths.
I find this troubling also. Is this a bug or a feature?
Friendly ping. This is a problem for adoption of rules_docker.
Setting strip_prefix in tar_pkg workaround helped in my case (not to ., but to specific directory, as in my layout I needed to strip some prefix):
pkg_tar(
name = "webfrontend-tar",
srcs = ["//webfrontend:build"],
mode = "0o644",
package_dir = "/usr/share/nginx/html/",
# Otherwise all directories are flattened:
# <https://github.com/bazelbuild/rules_docker/issues/317>
strip_prefix = "webfrontend/build/",
)
container_image(
name = "webfrontend-image",
tars = [":webfrontend-tar"],
base = "@nginx_base//image",
visibility = ["//visibility:public"],
)
Without strip_prefix = "webfrontend/build/", all files are flattened in webfrontend-tar.
is this still an issue? please reopen if so.
It is! I can鈥檛 reopen this issue, though
Is the workaround you found using pkg_tar noy working or otherwise problematic?
It鈥檚 problematic because it鈥檚 undocumented and unexpected. It鈥檚 really hard to understand why this happens or how to fix it without lots of googling. It鈥檚 another weird thing that you have to tell people about when they just want to try out Bazel (and there鈥檚 plenty of them, you know?)
I have updated the docs (See PR updating readme) to explain this issue. I'm closing this again as I dont think the fix for this issue is on this repo (i.e., it seems to me the issue is with pkg_tar rule). Please let me know if anyone feels there is more we can do here to reopen.
Most helpful comment
Setting
strip_prefixin tar_pkg workaround helped in my case (not to., but to specific directory, as in my layout I needed to strip some prefix):Without
strip_prefix = "webfrontend/build/",all files are flattened inwebfrontend-tar.