bazelbuild / bazelbuild/rules_pkg
document that directories are flattened unless data_path, strip_prefix are set to "."
- Dominant language
- Starlark
- Stars
- 253
- Forks
- 221
- Avg merge
- 10h 33m
- Merged PRs (30d)
- 1
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](https://github.com/jmhodges/docker_build_bug). 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 / https://github.com/bazelbuild/bazel/commit/0e222581e674b0f7c186c4bc40be2af680e94643 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
Contributor guide
Assessment
This issue has not been assessed yet.