The story of adding the latest Node.js to DockerFile

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

Premise

I needed to try touching wasm with Rust. Uses a buster-based container.

Conclusion

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

Thoughts

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.

Source

https://hub.docker.com/_/node https://github.com/nodejs/docker-node/blob/d58d7e65c4f92ef22a190b0ca835ce62464ff3ba/15/buster/Dockerfile

Recommended Posts

The story of adding the latest Node.js to DockerFile
The story of making the existing Dockerfile GPU compatible
The story of introducing Ajax communication to ruby
The story of raising Spring Boot 1.5 series to 2.1 series
The story of migrating from Paperclip to Active Storage
The story of raising Spring Boot from 1.5 series to 2.1 series part2
20190803_Java & k8s on Azure The story of going to the festival
The story of pushing Java to Heroku using the BitBucket pipeline
[Apache Tomcat] The story of using Apache OpenWebBeans to enable CDI
The story of @ViewScoped consuming memory
The story I wanted to unzip
The story of Collectors.groupingBy that I want to keep for posterity
The story of toString () starting with passing an array to System.out.println
From fledgling Java (3 years) to Node.js (4 years). And the impression of returning to Java
The story of encountering Spring custom annotation
About the version of Docker's Node.js image
The secret to the success of IntelliJ IDEA
The story of forgetting to close a file in Java and failing
The story of updating SonarQube's Docker Container
The story of switching from Amazon RDS for MySQL to Amazon Aurora Serverless
The story of releasing the Android app to the Play Store for the first time.
How to determine the number of parallels
The story of RxJava suffering from NoSuchElementException
The story of AppClip support in Anyca
Output of the book "Introduction to Java"
The story of writing Java in Emacs
The process of introducing Vuetify to Rails
How to check the latest version of io.spring.platform to describe in pom.xml of Spring (STS)
The story of low-level string comparison in Java
I want to output the day of the week
[Rails] Button to return to the top of the page
The story of making ordinary Othello in Java
A story addicted to EntityNotFoundException of getOne of JpaRepository
Add empty data to the top of the list
Customize how to divide the contents of Recyclerview
Make a margin to the left of the TextField
The story of learning Java in the first programming
Set the time of LocalDateTime to a specific time
The story of tuning android apps with libGDX
I want to var_dump the contents of the intent
How to get today's day of the week
Change the timezone of the https-portal container to JST
Output of how to use the slice method
[Ruby] Code to display the day of the week
Install the latest version of Jenkins on Ubuntu 16
How to display the result of form input
The story of initializing Money :: Currency when testing
[Java] How to get the authority of the folder
Java Welcome to the Swamp of 2D Arrays
We have extracted the best plastics of Dockerfile!
Use the --build-arg option of docker-compose to pass environment variables to the container built with Dockerfile
[Java] How to get the URL of the transition source
From the introduction of devise to the creation of the users table
How to delete / update the list field of OneToMany
Extend Highfaces to flip the vertical axis of the graph
How to write Scala from the perspective of Java
I was addicted to the record of the associated model
I tried to summarize the state transition of docker
Touch Glassfish 6 to commemorate the release of Jakarta EE 9
Convert the array of errors.full_messages to characters and output
[Ruby] How to find the sum of each digit