I wanted to install Node.js on the image I created elsewhere, but it didn't come out immediately after checking it, so a memo
I needed to try touching wasm with Rust. Uses a buster-based container.
Added this
ENV NODE_VERSION 15.0.1
RUN ARCH= && dpkgArch="$(dpkg --print-architecture)" \
&& case "${dpkgArch##*-}" in \
amd64) ARCH='x64';; \
ppc64el) ARCH='ppc64le';; \
s390x) ARCH='s390x';; \
arm64) ARCH='arm64';; \
armhf) ARCH='armv7l';; \
i386) ARCH='x86';; \
*) echo "unsupported architecture"; exit 1 ;; \
esac \
&& set -ex \
&& curl -fsSLO --compressed "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& tar -xJf "node-v$NODE_VERSION-linux-$ARCH.tar.xz" -C /usr/local --strip-components=1 --no-same-owner \
&& rm "node-v$NODE_VERSION-linux-$ARCH.tar.xz" \
&& ln -s /usr/local/bin/node /usr/local/bin/nodejs \
&& node --version \
&& npm --version
What I'm doing Get architecture Hit url on the official website Deployment
Version displayed in the log
+ node --version
v15.0.1
+ npm --version
7.0.3
At first I installed it with apt, but the version is old (I remember it was around 10), so I thought about updating it. However, I couldn't find the "correct" method even after searching properly, so I went to Docker Hub. https://hub.docker.com/_/node
From here, jump to DockerFile, an image based on an OS (this time buster) similar to the one you are using. Extract the part where node is installed from there and apply it to your Docker File. (Actually there was a checksum or something, but I deleted it)
It worked brilliantly. that's all.
https://hub.docker.com/_/node https://github.com/nodejs/docker-node/blob/d58d7e65c4f92ef22a190b0ca835ce62464ff3ba/15/buster/Dockerfile
Recommended Posts