fwouts / bazel-javascript

JavaScript and TypeScript rules for Bazel (React friendly)
MIT License
65 stars 17 forks source link

Introduce a dockerized NodeJS example #14

Closed fwouts closed 6 years ago

fwouts commented 6 years ago

This should help address part of #13.

@enriched could you give an example of native node module that would break with this?

enriched commented 6 years ago

@fwouts durable_rules is one that I have had break on me in the past. I also had a coworker complain about node-sass not working, which is probably more popular.

fwouts commented 6 years ago

Thanks, I got it failing successfully now. This might take a while to fix :)

fwouts commented 6 years ago

Hi @enriched, could you check the workaround df98825 above? I'm not sure if the Docker rules allow running these commands at build time. This seems suboptimal. What do you think of this approach? Any better ideas?

enriched commented 6 years ago

@fwouts It's possible that Bazel just doesn't have the concepts to address the native modules yet. I think that (in my limited understanding) the issues Skylark supports multi-architecture ("fat") binaries and Skylark supports platform transitions might add the concepts to Bazel that can deal with this?

I think that I could use something like dazel so that the yarn install was run inside a docker container. But I think that file IO with mounted volumes is fairly slow.

In the meantime, I think that your workaround looks like it would be the best solution. Probably a hit to startup time. Or I might be able to find a way to run that command with kaniko as a final build step.

fwouts commented 6 years ago

Thanks, lots of good ideas.

FYI I also toyed with the idea of setting the target platform with --platform but didn't get any positive results, because it looks like the Bazel rules themselves must implement some custom logic for this (yarn still ended up installing into node_modules/node-sass/vendor/darwin-x64-57 when using a Linux x64 target platform).

There's also https://github.com/bazelbuild/bazel-toolchains that looks interesting (but requires being run in a remote environment).

In the meantime, I'll get this merged in (the CircleCI error is unrelated (https://github.com/bazelbuild/bazel/issues/5964).