Ruby2.6.8 docker imageで何故かnode v10をインストールできない
対策結論
2.6.8-buster
イメージを使用する
経緯
古いRailsアプリケーションのバージョンアップ作業をしている中で遭遇。
Rubyのバージョンアップから進めており、Ruby2.6.0→Ruby2.7.0に更新した際、nodeのバージョンを10に指定しているにも関わらず、なぜか12になってしまいました。
検証の結果、2.6.7までは問題なく、2.6.8から発生することが判明しました。
Ruby2.6.7
FROM ruby:2.6.7 //... RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ && apt-get install -y nodejs \
root@b59a6e98ec4a:/var/www/app# node -v v10.24.1
Ruby2.6.8
FROM ruby:2.6.8 //... RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \ && apt-get install -y nodejs \
root@496f4fb0e931:/var/www/app# node -v v12.22.5
ビルドログを凝視すると違いがありました。
Ruby2.6.7
#10 [ 7/17] RUN apt-get install -y nodejs #10 sha256:5efae8405303b7a2bcad62cf4e2b5a1cef7808df3945af4cc652eb708cad4768 #10 0.290 Reading package lists... #10 1.078 Building dependency tree... #10 1.255 Reading state information... #10 1.527 The following NEW packages will be installed: #10 1.529 nodejs #10 1.703 0 upgraded, 1 newly installed, 0 to remove and 36 not upgraded. #10 1.703 Need to get 15.9 MB of archives. #10 1.703 After this operation, 80.5 MB of additional disk space will be used. #10 1.703 Get:1 https://deb.nodesource.com/node_10.x buster/main amd64 nodejs amd64 10.24.1-1nodesource1 [15.9 MB] #10 3.667 debconf: delaying package configuration, since apt-utils is not installed #10 3.705 Fetched 15.9 MB in 2s (8395 kB/s) #10 3.744 Selecting previously unselected package nodejs. (Reading database ... 24018 files and directories currently installed.) #10 3.772 Preparing to unpack .../nodejs_10.24.1-1nodesource1_amd64.deb ... #10 3.777 Unpacking nodejs (10.24.1-1nodesource1) ... #10 6.604 Setting up nodejs (10.24.1-1nodesource1) ... #10 DONE 7.1s
→#10 1.703 Get:1 https://deb.nodesource.com/node_10.x buster/main amd64 nodejs amd64 10.24.1-1nodesource1 [15.9 MB]
Ruby2.6.8
#10 [ 7/17] RUN apt-get install -y nodejs #10 sha256:3b2dc80a498093067ad65fe0fb4f0017f5ffb57f62b010cda059f672cb36a61d #10 0.310 Reading package lists... #10 1.055 Building dependency tree... #10 1.246 Reading state information... #10 1.532 The following additional packages will be installed: #10 1.535 javascript-common libc-ares2 libjs-highlight.js libnode72 libuv1 nodejs-doc #10 1.545 Suggested packages: #10 1.545 apache2 | lighttpd | httpd npm #10 1.599 The following NEW packages will be installed: #10 1.601 javascript-common libc-ares2 libjs-highlight.js libnode72 libuv1 nodejs #10 1.602 nodejs-doc #10 1.712 0 upgraded, 7 newly installed, 0 to remove and 25 not upgraded. #10 1.712 Need to get 11.7 MB of archives. #10 1.712 After this operation, 50.9 MB of additional disk space will be used. #10 1.712 Get:1 http://deb.debian.org/debian bullseye/main amd64 javascript-common all 11+nmu1 [6260 B] #10 1.737 Get:2 http://deb.debian.org/debian bullseye/main amd64 libc-ares2 amd64 1.17.1-1+deb11u1 [102 kB] #10 1.773 Get:3 http://deb.debian.org/debian bullseye/main amd64 libjs-highlight.js all 9.18.5+dfsg1-1 [397 kB] #10 1.937 Get:4 http://deb.debian.org/debian bullseye/main amd64 libuv1 amd64 1.40.0-2 [132 kB] #10 1.975 Get:5 http://deb.debian.org/debian bullseye/main amd64 libnode72 amd64 12.22.5~dfsg-2~11u1 [8333 kB] #10 5.188 Get:6 http://deb.debian.org/debian bullseye/main amd64 nodejs amd64 12.22.5~dfsg-2~11u1 [147 kB] #10 5.229 Get:7 http://deb.debian.org/debian bullseye/main amd64 nodejs-doc all 12.22.5~dfsg-2~11u1 [2545 kB] #10 6.419 debconf: delaying package configuration, since apt-utils is not installed #10 6.476 Fetched 11.7 MB in 5s (2579 kB/s) #10 6.507 Selecting previously unselected package javascript-common. (Reading database ... 22779 files and directories currently installed.) #10 6.541 Preparing to unpack .../0-javascript-common_11+nmu1_all.deb ... #10 6.561 Unpacking javascript-common (11+nmu1) ... #10 6.597 Selecting previously unselected package libc-ares2:amd64. #10 6.601 Preparing to unpack .../1-libc-ares2_1.17.1-1+deb11u1_amd64.deb ... #10 6.608 Unpacking libc-ares2:amd64 (1.17.1-1+deb11u1) ... #10 6.643 Selecting previously unselected package libjs-highlight.js. #10 6.648 Preparing to unpack .../2-libjs-highlight.js_9.18.5+dfsg1-1_all.deb ... #10 6.655 Unpacking libjs-highlight.js (9.18.5+dfsg1-1) ... #10 6.741 Selecting previously unselected package libuv1:amd64. #10 6.744 Preparing to unpack .../3-libuv1_1.40.0-2_amd64.deb ... #10 6.748 Unpacking libuv1:amd64 (1.40.0-2) ... #10 6.796 Selecting previously unselected package libnode72:amd64. #10 6.800 Preparing to unpack .../4-libnode72_12.22.5~dfsg-2~11u1_amd64.deb ... #10 6.803 Unpacking libnode72:amd64 (12.22.5~dfsg-2~11u1) ... #10 8.144 Selecting previously unselected package nodejs. #10 8.148 Preparing to unpack .../5-nodejs_12.22.5~dfsg-2~11u1_amd64.deb ... #10 8.152 Unpacking nodejs (12.22.5~dfsg-2~11u1) ... #10 8.196 Selecting previously unselected package nodejs-doc. #10 8.200 Preparing to unpack .../6-nodejs-doc_12.22.5~dfsg-2~11u1_all.deb ... #10 8.204 Unpacking nodejs-doc (12.22.5~dfsg-2~11u1) ... #10 8.608 Setting up javascript-common (11+nmu1) ... #10 8.657 Setting up libc-ares2:amd64 (1.17.1-1+deb11u1) ... #10 8.670 Setting up libuv1:amd64 (1.40.0-2) ... #10 8.684 Setting up libjs-highlight.js (9.18.5+dfsg1-1) ... #10 8.693 Setting up libnode72:amd64 (12.22.5~dfsg-2~11u1) ... #10 8.702 Setting up nodejs-doc (12.22.5~dfsg-2~11u1) ... #10 8.710 Setting up nodejs (12.22.5~dfsg-2~11u1) ... #10 8.734 update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode #10 8.743 Processing triggers for libc-bin (2.31-13+deb11u2) ... #10 DONE 8.9s
→#10 1.712 Get:1 http://deb.debian.org/debian bullseye/main amd64 javascript-common all 11+nmu1 [6260 B]
Ruby2.6.7ではdebian buster
を見に行くのに対し、2.6.8ではdebian bullseye
を見てます。
ビルド後OSの情報も覗いてみました。
Ruby2.6.7
root@cb6fa434cad2:/etc# cat /etc/*-release PRETTY_NAME="Debian GNU/Linux 10 (buster)" NAME="Debian GNU/Linux" VERSION_ID="10" VERSION="10 (buster)" VERSION_CODENAME=buster ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
Ruby2.6.8
root@496f4fb0e931:/etc# cat /etc/*-release PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
やはりバージョンの差異がありました。それぞれnodeの要件を見てみます。
パッケージ: nodejs (10.24.0~dfsg-1~deb10u1)
パッケージ: nodejs (12.22.5~dfsg-2~11u1)
Ruby2.6.8イメージではOSのバージョンがアップデートされており、nodeの要件の違いにより、v12がインストールされていたということでした。
docker imageとしてはそれぞれ2.6.8-bullseye
と2.6.8-buster
が存在していたので、盲点でした…。
ということで、一旦は2.6.8-buster
を使用してアップデート作業を進めていくことで解決しました。
※ ツッコミどころであるnodeとOSのバージョンアップは別途対応