こんかなんじになりました。
image: "bradrydzewski/node:0.10"
cache:
- /tmp/npm
- /tmp/node_modules
- /tmp/bower_components
script:
- pwd
- whoami
- mkdir -p /tmp/{npm,node_modules,bower_components}
- ls -la /tmp/{npm,node_modules,bower_components}
- sudo chown -R ubuntu:ubuntu /tmp/{npm,node_modules,bower_components}
- ln -snf /tmp/npm /home/ubuntu/.npm
- ln -snf /tmp/node_modules node_modules
- ln -snf /tmp/bower_components app/bower_components
- time npm install -g coffee karma yo generator-angular grunt-cli bower # -g cannot use cache
- time npm install
- time bower install --allow-root --config.interactive=false
- time grunt test
$(pwd)/node_modules
は npm install でモジュールがインストールされるディレクトリで、$HOME/.npm
はその時にキャッシュが入るディレクトリ。両方とも、/tmp 以下の cache: で指定したディレクトリに symlink 貼っている。
同様の方法で bower の cache も利かせている。
npm install -g は npm config set prefix
でインストール場所を変更することができたが、そもそも -g だと再利用してくれないようで意味がなかった。