rules_js icon indicating copy to clipboard operation
rules_js copied to clipboard

Promote js_image_layer to Public API

Open thesayyn opened this issue 3 years ago • 2 comments

js_image_layer should be promoted to public API before 1.0

thesayyn avatar Jul 25 '22 18:07 thesayyn

Not landing this for 1.0 since there are transitive deps on rules_py and rules_pkg that we have to reason about first

gregmagolan avatar Aug 04 '22 19:08 gregmagolan

As spoken with @thesayyn on Slack, I tested the js_image_layer following the example on the e2e folder and noticed something additional had to be done when importing files. It can be either improved or be part of the docs.

When running the image built using js_image_layer, my Node.js runtime at first wasn't able to find some .proto files that I import. It all works great when using js_binary directly though. But to get the files to be found with this Starlark code I'm importing from the e2e folder, I had to:

  • Set the workdir attribute in the container_image to /app/my_package/start.sh.runfiles/my_workspace_name (/app is the root in js_image_layer). It also works if I set the environment variable JS_BINARY__CHDIR to that same string.
  • After setting the workdir as mentioned above, I still need to prefix the file I import with process.cwd(). When I call the js_binary target directly without Docker, I don't need to prefix it.

bazaglia avatar Aug 12 '22 08:08 bazaglia

https://github.com/bazel-contrib/rules_oci/pull/31#discussion_r1030938473 we'll move the python bit to its own file if we can't address #381

thesayyn avatar Nov 24 '22 04:11 thesayyn