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

Inquiry - How to build ts_project with rules_docker? #3421

Closed
twheys opened this issue Apr 22, 2022 · 4 comments
Closed

Inquiry - How to build ts_project with rules_docker? #3421

twheys opened this issue Apr 22, 2022 · 4 comments

Comments

@twheys
Copy link
Contributor

twheys commented Apr 22, 2022

Hello, I am trying to build my Bazel typescript project into a docker container using the container_image rule from rules_docker. Is there any recommended solution for setting the rootDirs?

"compilerOptions": {
    "rootDirs": [
        ".",
        "../../bazel-out/host/bin/path/to",
        "../../bazel-out/darwin-fastbuild/bin/path/to",
        "../../bazel-out/darwin_arm64-fastbuild/bin/path/to",
        "../../bazel-out/k8-fastbuild/bin/path/to",
        "../../bazel-out/x64_windows-fastbuild/bin/path/to",
        "../../bazel-out/darwin-dbg/bin/path/to",
        "../../bazel-out/k8-dbg/bin/path/to",
        "../../bazel-out/x64_windows-dbg/bin/path/to",
    ]
}

The issue with rules_docker is that it uses a Bazel transition which builds all of the ts_project targets in a different Bazel output dir which is suffixed with some hash that appears to change based on some factors unbeknownst to me (ie darwin_arm64-fastbuild-ST-4a519fd6d3e4), which makes it impossible to use the rootDirs workaround.

Is there any known solution to overcome this?

@alexeagle
Copy link
Collaborator

microsoft/TypeScript#37378 is the root cause bug.

https://github.com/bazelbuild/rules_nodejs/wiki/Migrating-to-5.0#nodejs_image-from-rules_docker documents this

You may also need to add more rootDirs entries to tsconfig since there is another output directory, see bazelbuild/rules_docker#1963 (comment)

@alexeagle
Copy link
Collaborator

Oh, and since I doubt the TypeScript team will ever resolve that issue or accept our PR, ultimately the likely fix seems to be our new approach in rules_js where we give up on teaching NodeJS about a "source tree and an output tree" and just run all node programs exclusively in the output tree.

@twheys
Copy link
Contributor Author

twheys commented Apr 22, 2022

Thanks for the feedback. Too bad we can't just write a glob pattern for root patterns and paths with typescript, that would solve this. On the other hand, it's quite annoying how bazel maintains the output directory structure inside the sandboxes but I guess that is necessary for a local strategy.

@twheys
Copy link
Contributor Author

twheys commented Apr 22, 2022

On the plus side, it seems like the transition output dirs are deterministic, I'm just not sure what parameters go into them. I know it uses at least the os, cpu, and bazel version.

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

2 participants