node.js - Using docker and docker-compose in order to run npm install and bower install -
i trying use docker node image in order run npm install
, bower install
.
here relevant portion docker-compose.yml
:
node: image: node:0.10.40 volumes: - ./package.json:/package.json - .bowerrc:/.bowerrc - ./bower.json:/bower.json - ./build/npm.tmp/node_modules:/node_modules - ./build/npm.tmp/bignibou-client/src/bower_components:/bignibou-client/src/bower_components command: bash -c "npm install && bower install" ports: - "8888:8888"
unfortunately following error node:
node_1 | bash: bower: command not found bignibousite_node_1 exited code 127
indicating command not interpreted properly.
i have tried using post-script in package.json follows:
"scripts": { "postinstall": "/node_modules/bower/bin/bower install" }
here .bowerrc
:
{ "json": "bower.json", "directory": "bignibou-client/src/bower_components" }
without bower install, npm install
run ok. bower install
cannot work.
can please help?
edit: postinstall script above gives me error node:
node_1 | npm warn cannot run in wd bignibou-client@0.1.0 /node_modules/bower/bin/bower install (wd=/)
edit 2: tried solution suggested alexis i.e. using existing image tried specify local bower.json, etc. follows:
docker run -it --rm \ -v ./package.json:/package.json \ -v .bowerrc:/.bowerrc \ -v ./bower.json:/bower.json \ -v ./build/npm.tmp/node_modules:/node_modules \ -v ./build/npm.tmp/bignibou-client/src/bower_components:/bignibou-client/src/bower_components \ digitallyseamless/nodejs-bower-grunt bower install
i error though:
/usr/local/lib/node_modules/bower/node_modules/bower-config/node_modules/graceful-fs/polyfills.js:224 throw er ^ error: eisdir, illegal operation on directory @ error (native) @ object.fs.readsync (fs.js:552:19) @ object.fs.readsync (/usr/local/lib/node_modules/bower/node_modules/bower-config/node_modules/graceful-fs/polyfills.js:218:23) @ object.fs.readfilesync (fs.js:384:28) @ /usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:75:27 @ array.foreach (native) @ json (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:74:14) @ rc (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:31:9) @ config.load (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/config.js:14:20) @ function.config.read (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/config.js:49:19)
i not sure why , how sort out.
i think should install bower globally in image
create dockerfile
:
from node:0.10.40 run npm install -g bower
and reference in docker-compose.yml file
node: build: . // <= path folder containing dockerfile ...
otherwise, there popular image on dockerhub digitallyseamless/nodejs-bower-grunt provides it.
Comments
Post a Comment