gorules / zen

Open-source Business Rules Engine for your Rust, NodeJS, Python or Go applications.
https://gorules.io
MIT License
767 stars 74 forks source link

Feature request: linux-musl support #44

Open jdrydn opened 1 year ago

jdrydn commented 1 year ago

Hi guys! We're running Zen with NodeJS in our project (fab library & visual editor btw 👏👏👏), working locally (node:16.19.1 running on Apple Silicon) but fails when deploying to cloud (node:16.19-alpine3.14 container) with the error:

/app/node_modules/@gorules/zen-engine/index.js:244
    throw loadError
    ^

Error: Cannot find module '@gorules/zen-engine-linux-arm64-musl'
Require stack:
- /app/node_modules/@gorules/zen-engine/index.js
- /app/dist/app.js
- /app/dist/server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/app/node_modules/@gorules/zen-engine/index.js:200:31)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/app/node_modules/@gorules/zen-engine/index.js',
    '/app/dist/app.js',
    '/app/dist/server.js'
  ]
}

After reviewing the Zen Engine README, there's this lovely lil' line at the end:

https://github.com/gorules/zen/blob/ccca4df2e6184d5c3b87be31d176e332d2ad45cc/README.md?plain=1#L177

So quick-fix for us for now is to drop Alpine from our package:

- FROM node:16.19-alpine3.14
+ #FROM node:16.19-alpine3.14
+ FROM node:16.19

But this may not be an acceptable solution in all use-cases!

Will there ever be support for linux-musl (perhaps by installing additional libs with apk)?

stefan-gorules commented 1 year ago

Hi @jdrydn thank you for the amazing feedback and detailed report.

The constraint exists due to rusty_v8 crate which is being used for function nodes. We are exploring other alternatives and debating if we should switch to another v8 crate, move to JSC (JavaScript Core) or start building our own from the source.

For the time being it is indeed not possible, I will leave this issue open so we can track it in future.

stefan-gorules commented 1 year ago

Just to provide an update here, we are exploring BoaJS as a replacement for V8, nothing is set in stone (as it's still somewhat experimental, and lacks some functionalities that we need for high-performance circumstances), but it would allow us to build for other architectures as well.

mercs600 commented 6 months ago

hi, any update here? it would be useful to use alpine version instead of an full image

stefan-gorules commented 6 months ago

@mercs600 Hi, we've recently moved from using V8 to QuickJS which will likely be able to compile to MUSL. We'll have a look into it soon.

However, I'd like to note that in most cases MUSL architecture leads to degraded performance in exchange for smaller Docker sizes, which may or may not be what you want.