mhart / alpine-node

Minimal Node.js Docker Images built on Alpine Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Node version 8 in version 10 images

jahbini opened this issue · comments

I have been getting odd installation messages from yarn saying the node version was snafu.

I ran this docker build on an alpine 10 image, and at step 8, node says it is version 8

Thought you might want to know.

(base) bigmak:thea jahbini$ docker build -t jahbini/site-master:latest site-master
Sending build context to Docker daemon 4.017MB
Step 1/12 : FROM mhart/alpine-node:slim-10.22
---> 41eaac03b675
Step 2/12 : MAINTAINER jim@bamboocando.com
---> Using cache
---> fd96abf5e5ec
Step 3/12 : RUN mkdir /site-master && apk update
---> Using cache
---> 0b2ac9bbe6b0
Step 4/12 : RUN apk add curl python git make yarn
---> Using cache
---> 1cb15b43b75d
Step 5/12 : RUN yarn add global gulp-cli
---> Using cache
---> af3e01dddb79
Step 6/12 : WORKDIR /site-master
---> Using cache
---> 27bef187bebe
Step 7/12 : ADD . /site-master
---> a80ef7337803
Step 8/12 : RUN node -v
---> Running in 527763e74bbc
v8.9.3
Removing intermediate container 527763e74bbc
---> 615a24325b0f

If you're adding Node.js dependencies using apk (like yarn), then Alpine will bring in its own node as a dependency for these. It doesn't know that you already have node

The non-slim images already have yarn on them – you should use these for installation instead. ie, mhart/alpine-node:10.22

The README has an example of how to do the installation using the non-slim image, and then copy everything over to the slim image for running in production (because you shouldn't need make, python, etc for your app): https://github.com/mhart/alpine-node#example-dockerfile-for-your-own-nodejs-project

Just swap out npm for yarn in those instructions if you prefer yarn

In the apk add step you should be able to see what it's doing. I see:

# ...
(2/9) Installing nodejs-npm (8.9.3-r1)
# ...

A subtle, but aromatic snafu with undertones of versioning purgatory.

Thank you for your excellent second pair of eyes on my build -

And an excellent pointer to better practices.