Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Nodejs 8.12 in alpine:3.8?

I am writing a Dockerfile to dockerize a sample nodejs app. I developed that in Nodejs v8.12 and npm 6.4.1. I know that I can use node:8.12-alpine image to get results. But I am using alpine:3.8 image which is officially recommended.

My Dockerfile contents are below if I use that to build image I will end up in downloading latest version of nodejs from alpine repo. I don't want that to happen, So I planned to install the package manually for the purpose of reproducible. The saddest part is I am unable to find apk version of Nodejs v8.12 and npm.

Can any one help me on where can I find apk for Nodejs v8.12 or how to install this version of Nodejs to my image manually?

FROM alpine:3.8 WORKDIR /app RUN apk add --update nodejs nodejs-npm COPY . ./ RUN npm install EXPOSE 9001 CMD [ "npm", "start" ]

like image 891
Karthick Avatar asked Nov 20 '18 08:11

Karthick


People also ask

Does Alpine have Nodejs?

Alpine LinuxNode.js LTS and npm packages are available in the Main Repository. Node.js Current can be installed from the Community Repository.

Does node Alpine have npm?

RUN apk add --update nodejs npm will use the Alpine package manager to grab Node. js and npm (they're bundled separately for Alpine.)


1 Answers

The question already answered but today I was facing issue so this is how i build with nodejs 8 in Alpine

FROM alpine:3.8
RUN apk add  --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.7/main/ nodejs=8.9.3-r1

You can find node 8 in Alpine repo v3.7

https://pkgs.alpinelinux.org/packages?name=nodejs&branch=v3.7

enter image description here

you can find node version details here, branch convention is v3.x

like image 124
Adiii Avatar answered Oct 25 '22 16:10

Adiii