Search code examples
node.jsdockernpmbowerbower-install

Dockerizing npm & bower install using the digitallyseamless/nodejs-bower-grunt docker image


I am trying to use docker in order to run npm & bower install.

Here is my configuration:

./package.json

{
  "name": "bignibou-client",
  "version": "0.1.0",
  "engines": {
    "node": "0.10.x"
  },
  "devDependencies": {
    "bower": "1.3.12",
    "grunt": "~0.4.5",
    "grunt-contrib-uglify": "~0.6.0",
    "grunt-contrib-concat": "~0.5.0",
    "karma": "~0.12.23",
    "grunt-karma": "~0.9.0",
    "karma-junit-reporter": "~0.2.2",
    "karma-jasmine": "~0.1.5",
    "karma-phantomjs-launcher": "~0.1.4",
    "phantomjs": "~1.9.11",
    "grunt-mkdir": "~0.1.2",
    "grunt-contrib-cssmin": "~0.10.0",
    "grunt-contrib-clean": "~0.6.0",
    "grunt-contrib-copy": "~0.7.0",
    "karma-htmlfile-reporter": "~0.1.2",
    "grunt-filerev": "~2.1.2",
    "grunt-usemin": "~2.6.2",
    "grunt-protractor-runner": "~1.1.4",
    "protractor": "~1.4.0",
    "flow": "~0.2.3",
    "assemble-less": "~0.7.0"
  },
  "scripts": {
    "postinstall": "node_modules/bower/bin/bower install"
  }
}

.bowerrc

{
    "json": "bower.json", "directory": "bignibou-client/src/bower_components"
}

My command:

docker run --privileged=true -it --rm \
   -w /usr/src/app \
   -v $(pwd)/package.json:/usr/src/app/package.json  \
   -v $(pwd)/.bowerrc:/usr/src/app/.bowerrc \
   -v $(pwd)/./bower.json:/usr/src/app/bower.json  \
   -v ./build/npm.tmp/node_modules:/usr/src/app/node_modules  \
   -v ./build/npm.tmp/bignibou-client/src/bower_components:/usr/src/app/bignibou-client/src/bower_components \
   digitallyseamless/nodejs-bower-grunt npm install

I just get the following console output:

npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No license field.

and nothing is generated on the host...

Can someone please provide advice as to how to get it working or an alternative solution?

edit:

Running the following command:

docker run --privileged=true -it --rm \
-w /usr/src/app \
-v $(pwd):/usr/src/app \
digitallyseamless/nodejs-bower-grunt npm install

results in:

npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No license field.
npm WARN cannot run in wd [email protected] node_modules/bower/bin/bower install (wd=/usr/src/app)

Solution

  • -v $(pwd)/package.json:/usr/src/app/package.json

    this flag will create a package.json directory but not the file.

    Here is how your command should look like:

    docker run --privileged=true -it --rm \
    -w /usr/src/app \
    -v $(pwd):/usr/src/app\
    digitallyseamless/nodejs-bower-grunt bash -c "npm install && bower --allow-root install"
    

    And after this script create node_modules and bower_components in current directory on HOST mashine and you can manipulate with result as you wish.