うっかりビルドし直したらnodeだかnpmだか、なんかが新しくなってて急激に怒られたのでその時のメモ。
Immutable Infrastructureとはいったい
ちょいちょい最新を取ってきちゃうような、あやふやな設定書いてる自分が悪い。
- コンテナはrootで何もかもが動いている
- aptでnodeを取りに行っていたが、最新じゃないからサポートしてやらない的なことをブツブツ言われるので
v10.16.2
のバイナリを落としてきてインストールするようにした(問題のエラーとは直接関係のある変更ではなさそう) - Dockerfileでは
-g
で入れるwebpack等だけRUNでコマンドが書かれていて、アプリが使う諸々は別途シェルスクリプトを書きcmd start.sh
で起動、まるっとセットアップ(npm i --frozen-lockfile
みたいな)している - frozen-lockfileが何かは知らないがバージョン固定でライブラリ入れてるんだろうねくらいの理解
- なんでこんな薄いかんじで使ってんのかというと連携先アプリを開発環境に取り込んで起動してるから
- 2019年6月くらいまでは起きなかったトラブル(のはず)。nodeになんかあったんでしょ知らんけど
永久に出るエラーの例
gyp verb ensuring nodedir is created /usr/src/app/node_modules/node-sass/.node-gyp/10.16.2
gyp WARN EACCES user "undefined" does not have permission to access the dev dir "/usr/src/app/node_modules/node-sass/.node-gyp/10.16.2"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/src/app/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '10.16.2' ]
gyp verb install input version string "10.16.2"
gyp verb install installing version: 10.16.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 10.16.2
このnode-sassさんがなんかやらかしたの?とも思ったが、
user "undefined" does not have permission
まあこれですよねという感じ。undefined氏は私も知らない人です。
解決した一打
Dockerfileにこれいれる。
RUN npm -g config set user root
参考
No access permission error with npm global install on docker image - Stack Overflow
Global install file-ownership “nobody” - is this really sane ? · Issue #3849 · npm/npm