aspect-build / aspect-build/rules_js
[Bug]: js_binary script launcher doesn't work with Alpine(dash) and no way to disable runfiles
- Dominant language
- Starlark
- Stars
- 378
- Forks
- 183
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 32
Description
### What happened?
I'm trying to convert an existing project into rules_js + rules_oci. The examples suggests that it should be fine to use ```js_binary``` combined with ```js_image_layer``` as input to ```oci_image```. The problem is I wanted to use node:lts-alpine as my base image and the launcher script doesn't seem to work with Alpine's default shell dash:
```console
18:20 $ docker run --rm -it my-image:latest
/app/my-image/main: /app/my-image/main.runfiles/_main/my-image/main.sh: line 160: syntax error: unexpected redirection
```
Looking into making a PR for this, but not sure how to create a test for it.
### Version
Development (host) and target OS/architectures: MacOS / amd64
Output of `bazel --version`: aspect 5.7.2
Version of the Aspect rules, or other relevant rules from your
`WORKSPACE` or `MODULE.bazel` file:
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "rules_jvm_external", version = "5.3")
bazel_dep(name = "contrib_rules_jvm", version = "0.13.0")
bazel_dep(name = "aspect_bazel_lib", version = "1.32.1")
bazel_dep(name = "aspect_rules_js", version = "1.32.2")
bazel_dep(name = "aspect_rules_ts", version = "2.0.0")
bazel_dep(name = "aspect_rules_jest", version = "0.19.5")
bazel_dep(name = "rules_nodejs", version = "6.0.1")
bazel_dep(name = "rules_oci", version = "1.4.0")
Language(s) and/or frameworks involved:
TS, Node.js, rules_oci, Docker
### How to reproduce
```shell
# You can use an empty main.js
js_binary(
name = "main",
data = [":compile"],
entry_point = "main.js",
enable_runfiles=False,
)
js_image_layer(
name = "layers",
binary = ":main",
platform = "//:amd64_linux",
root = "/app",
visibility = ["//visibility:__pkg__"],
)
oci_image(
name = "image",
base = "@node-lts",
cmd = ["/app/docs-service/assets-server/main"],
entrypoint = ["/bin/sh"],
tars = [
":layers",
],
)
oci_tarball(
name = "tarball",
image = ":image",
repo_tags = ["syncron/cao/rnd.tools/docs-service:latest"],
)
```
### Any other information?
The offending lines seems to be:
* https://github.com/aspect-build/rules_js/blob/main/js/private/test/shellcheck_launcher.sh#L160 -- easy to replace with plain echo
* https://github.com/aspect-build/rules_js/blob/main/js/private/test/shellcheck_launcher.sh#L410 -- dash doesn't support arrays
Removing ```--enable_runfiles``` from ```.bazelrc``` does nothing (launcher still generated) and trying to pass ```enable_runfiles=False``` to the rule explicitly yields an error:
```console
File "***/external/aspect_rules_js~1.32.2/js/defs.bzl", line 30, column 15, in js_binary
_js_binary(
Error in js_binary: rule(...) got multiple values for parameter 'enable_runfiles'
```
Contributor guide
Research direction
Reproduce the Alpine failure with the js_binary, js_image_layer, and oci_image configuration in the issue, then inspect js/private/test/shellcheck_launcher.sh around lines 160 and 410. The work is done when the generated launcher runs under dash and the js_binary enable_runfiles setting can be disabled without the reported duplicate-parameter error; add or locate regression coverage as needed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, javascript, node.js, shell, typescript
- Domain
- build-system, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100