aspect-build / aspect-build/rules_js
[FR]: js_image_layer support for distroless images
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What is the current behavior?
Right now if you use `js_image_layer`, it creates a [bash launcher](https://github.com/aspect-build/rules_js/blob/main/js/private/js_image_layer.bzl#L201) which typically we use as the entrypoint for running the program built by `js_binary` in a containerized environment.
This works fine, but there is a requirement on using an image with `bash` available in it. For security reasons, it may be desirable to use [distroless images](https://github.com/GoogleContainerTools/distroless) and one of the things they avoid is having the ability to shell into the container/pod.
### Describe the feature
It would be nice for `js_image_layer` to also support a launcher that doesn't rely on bash. One option is to support native launcher (maybe written in go as example or a prebuilt binary) that preserves the behavior of the program (the environment variable and making runfiles available). We wrote a custom rule for this ourselves and packaged it as the entrypoint in rules_js. There's possibly other options too, I'm probably not aware of.
It feels like this could be part of rules_js with `js_image_layer` as this could be a common usecase but I understand if you think owners of apps need to build this tooling themselves (in which case we can close this issue).
Contributor guide
Research direction
Start with js/private/js_image_layer.bzl at the launcher creation referenced in the issue, then trace how js_image_layer invokes js_binary in a container. Compare the existing bash launcher behavior with the stated requirements for environment variables and runfiles, and review the distroless constraint. Done means js_image_layer supports a launcher that works without bash while preserving those behaviors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100