-
Notifications
You must be signed in to change notification settings - Fork 208
Description
In bazel 0.4.1 (and I think 0.3.2), if you give docker_build a filegroup with a glob that contains multiple directories of files, those files will be flattened into one directory.
Here's the repo I made for the reproduction. It needed a bit of set up. (You'll need xz installed to get the wheezy rootfs file unpacked.)
If you run bazel run //subdir:buggy_flatten_image, I expected a /foo/quux and a /bar/quux file to exist in the created image but instead only a /quux exists (verifiable with a docker run -it bazel/subdir:buggy_flatten_image). A warning about duplicate filepaths is given but not error occurs.
The addition of data_path = "." as in the //subdir:has_subdirs_image target fixes this and that's very surprising.
I think it's inheriting some behavior from pkg_tar's strip_prefix maybe, but it's definitely not what I expected and finding the solution wasn't easy, either. This also makes it difficult to merge together multiple filegroups with subdirectories into one image because you have to give each of them their own docker_build (or, perhaps, pkg_tar) in order to keep them from ending up at /.
Seems like this, or something similar, was addressed in bazelbuild/bazel#677 / bazelbuild/bazel@0e22258 but maybe something has happened in between then and now.
(I noticed this when a build was throwing up warnings, but not errors, of duplicate filepaths being included. Maybe that should be another ticket?)
Environment info
- Operating System:
macOS 10.12 Sierra
- Bazel version (output of
bazel info release):
release 0.4.1-homebrew