2021-12-19

npx dockerize-npm-module


Thinking aloud on challenge I am facing as JS developer.

Problem: NPM-based projects often require specific dependencies versions installation and version tune up which is 

  • time consuming ( curse of node-gyp or sass )
  • could mess up machine environment for other projects. 
Such dev and build dependencies could be pre-configured and jailed within docker image exposing only input/output folders and working ports on developer's machine.  

GitHub and other code management repositories are given ability to run continuous integration (CI) steps as Docker container actions

Those actions could be run as part of CI during deployment but also locally to prevent aforementioned problems. 

Solutionhttps://github.com/nektos/act - locally installed "act' app.

PROS: almost complete CI/CD cycle coverage. 

CONS: requires installation and ? per-project tune-up.

Proposal: npx dockerize-npm-module [NPM_SCRIPT_COMMAND]

Seamless as non-installable CLI to run all package.json commands in preconfigured image for docker container.

+ config generation/load

? reuse GitHub container actions  

+ upgrade package.json with safe:xxx scripts meant to run same NPM commands in docker container or add docker CI/CD steps.