-
Notifications
You must be signed in to change notification settings - Fork 94
Not able to add generated js files to docker image #263
Comments
@abqadeer I wasn't able to get these rules working very well for creating dockerized node servers, and it seems like most of the development here is focused on frontend development. I am currently using the bazel-javascript rules developed by zenclabs. The main contributor for those was kind enough to write up a dockerized example. I have successfully built some of our production containers on a mac and am working right now on some fixes to make it work for windows. If you do want to stick with the official Bazel rules then you will probably want to check out the es6_output example. As far as I know you need to create a rule that will gather all the es6 sources and list them as outputs. Or you need to use something like the rollup_bundle rule to output a single js file that you can include in your docker image. But I think that if you go with that route you will not be able to use any native nodejs modules. |
@abqadeer We use https://github.com/bazelbuild/rules_docker#nodejs_image and it works with TypeScript. Is there a reason you don't want to use the rule specifically designed for Nodejs code? |
@nimerritt nodejs_image is the rule that i ended up using, i did try it in the start but it didn't work(the issue was that i was building the code in on mac,
|
@abqadeer I was running into the same issue. Would love to hear about any solutions that you come up with. |
@enriched a build server is most likely to have linux on it, so you would not have this issue on a actual build server, i tested building my code on a VM running linux and it worked. But the problem is still there if i build and run on mac. |
so at this point you do have the .js files in the docker image, but end up with nodejs executable for the host platform (where you did the build) rather than the target platform? |
Yes, so |
Mac OS X, bazel //workspaces:ls outputs only one file - index.d.ts. Where is compiled index.js?
|
I think the remaining issue here is resolved by bazel-contrib/rules_nodejs#827 which would make @olegsmetanin I think you have a separate question? the default output of |
@olegsmetanin @abqadeer
usage:
Keep in mind this rule does not pick up npm deps. |
I am using
docker_build
rule fromrules_docker
https://github.com/bazelbuild/rules_docker#container_image-1 to build a docker image. My code is pretty basic anindex.ts
file withconsole.log()
and call to a function in another file which also logs a message.When i build the my code using
ts_library
the output i get on terminal is the location ofd.ts
files only, and not thejs
files. Thedocker_build
rule has argumentfiles
which accepts an array and i am giving it the output fromts_library
which only prints the location ofd.ts
files. My image builds successfully but only thed.ts
files are added to it.I have tried to use the
glob()
function but it can only be used for the source files not the generated file.Is this possible to output the location of
js
files in addition tod.ts
files?Is there some other way to add files to docker?
I have tried other rules but none works for my specific case. Also i think if
rules_typescript
output the location ofjs
files the problem will be solved.Here is how my BUILD file looks
The text was updated successfully, but these errors were encountered: