Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deprecation warning when installing nodejs on docker container using nodesource install script

I used to install nodejs on Debian based container using the following in the Dockerfile:

RUN apt-get update -yq && apt-get upgrade -yq && apt-get install -yq curl git nano
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - 
RUN apt-get install nodejs -y 

But I recently started getting the following message:

    => [base 3/7] RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
                               SCRIPT DEPRECATION WARNING
    ================================================================================ 
TO AVOID THIS WAIT MIGRATE THE SCRIPT Continuing in 60 seconds (press Ctrl-C to abort) ...

How do I fix it?

like image 521
Jesús López Avatar asked Aug 31 '25 02:08

Jesús López


1 Answers

The notice from the script is

  This script, located at https://deb.nodesource.com/setup_X, used to
  install Node.js is deprecated now and will eventually be made inactive.

  Please visit the NodeSource distributions Github and follow the
  instructions to migrate your repo.
  https://github.com/nodesource/distributions 

  The NodeSource Node.js Linux distributions GitHub repository contains
  information about which versions of Node.js and which Linux distributions
  are supported and how to install it.
  https://github.com/nodesource/distributions

The instructions on github amount to a Dockerfile RUN

FROM docker.io/debian:12-slim
RUN set -uex; \
    apt-get update; \
    apt-get install -y ca-certificates curl gnupg; \
    mkdir -p /etc/apt/keyrings; \
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
     | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg; \
    NODE_MAJOR=18; \
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
     > /etc/apt/sources.list.d/nodesource.list; \
    apt-get -qy update; \
    apt-get -qy install nodejs;

The docker.io/node:18 image maintained by the Node.js project is Debian based if you want to save some time.

FROM docker.io/node:18-bookworm-slim
like image 80
Matt Avatar answered Sep 02 '25 16:09

Matt