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

pkg_tar places all data dependency files/runfiles in root #811

Closed
yuan-attrove opened this issue Jan 13, 2024 · 2 comments
Closed

pkg_tar places all data dependency files/runfiles in root #811

yuan-attrove opened this issue Jan 13, 2024 · 2 comments

Comments

@yuan-attrove
Copy link

yuan-attrove commented Jan 13, 2024

Context

I have a web server written in Go. I have a folder of html template files as data dependencies in a go_library target, i.e.

file_group = (
  name = "my_templates",
  srcs = ["path/to/my/.html"],
)

go_library = (
  ...
  data = [":my_templates"]
)

I am currently using rules_docker which correctly preserves the folder structure of runfiles that my Go code relies to serve the html templates.

Since rules_docker is now deprecated I am trying to migrate to rule_oci and thus pkg_tar in rules_pkg.

The problem

With pkg_tar, the data dependencies no longer reside in the same folder as layered out by bazel build. Instead every file is flatten into the root directory.

I thought v0.10.0 would solve the problem judging from #579. But seems like it only does so for Python?

For my Go project setup,

go_library(
    name = "server_lib",
    srcs = ["main.go"],
    ...
)

go_binary(
    name = "server",
    embed = [":server_lib"],
    ...
)

pkg_tar(
    name = "server-tar",
    srcs = [":server"],
    include_runfiles = True,
)

oci_image(
    name = "server-image",
    base = "@distroless_base",
    entrypoint = ["/server"],
    tars = [":server-tar"],
)

After bazel build :server the runfiles lie in bazel-bin/server_/server.runfiles/_main/.

#579 (comment) describes exactly what rules_docker does and what I need.

@yuan-attrove
Copy link
Author

If I use a pkg_files with include_runfiles = True, then have pkg_tar depend on it, the output image seems correct. So maybe #754 missed something?

@yuan-attrove
Copy link
Author

Sorry I was wrong; although it's still different from how rules_docker layers files, the runfiles are there with pkg_tar v0.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant