s2i-nodejs-container icon indicating copy to clipboard operation
s2i-nodejs-container copied to clipboard

Need Monorepo support

Open kunyan opened this issue 4 years ago • 1 comments

Monorepo is becoming more and more popular repo style in Node.js ecosystem. It support the developers could arrange the packages as they want and link them together.

The current s2i steps looks not support monorepo. I can show some example which I met

the monorepo folders are like this

  • packages/
    • foo/
      • src/
      • README.md
      • package.json
    • bar/
      • src/
      • README.md
      • package.json
  • .eslintrc
  • package.json

Some common devDependencies had been install to the root package.json. like eslint, typescript and others So the foo and bar won't need to install them.

If I need build the foo only, For current s2i workflow, I have 2 choice.

1 Use git contextDir

  1. Clone the repo and set the contextDir to foo.
  2. Run npm run build, however, some dependencies only installed in root, so we will got error

2. Hack the build scripts

  1. Clone the repo from root
  2. Install all dependencies, and add post install to install all dependencies in child packages
  3. Add some env vars to make build script could detect which package I want to build

Solution

I think the only way to fix this issue for now is make the build command to a env vars. make user could custom it(Like $NPM_RUN)

Add a $NPM_BUILD might be the most easy way to resolve it

kunyan avatar Dec 19 '21 03:12 kunyan

I was kindof assuming that the NPM_RUN env var would be doing that. iow if present run an alternative build script during openshift Build and running an alternatif start script for the openshift Deploy. But this indeed doesn't seem to be the case.

KrisLamote avatar Oct 03 '22 10:10 KrisLamote

Hi @kunyan, do you consider this issue fixed by https://github.com/sclorg/s2i-nodejs-container/pull/424 being merged?

zmiklank avatar Apr 11 '24 10:04 zmiklank

@zmiklank $NPM_BUILD is a good for some monorepo use nx or lerna

kunyan avatar Apr 17 '24 02:04 kunyan