Search code examples
dockernginxangular-clidocker-containerdocker-image

How to get rid of "The Angular CLI requires a minimum Node.js" error during the creation of a docker image


Whenever I run the following command to create a Docker image,

docker build -t ehi-member-portal:v1.0.0 -f ./Dockerfile .

I get the following results

enter image description here

I'm not sure why it is complaining about Node version because I am currently running

enter image description here

And I am not sure why it is detecting v12.14.1 when you see I am running v14.20.0. I installed Node and NPM using NVM. I used this site as a reference to how to create the node and ngix image for a container.

Here is the contents of my Dockerfile:

FROM node:12.14-alpine AS builder
WORKDIR /dist/src/app
RUN npm cache clean --force
COPY . .
RUN npm install
RUN npm run build --prod


FROM nginx:latest AS ngi
COPY --from=builder /dist/ehi-member-portal /usr/share/nginx/html
COPY /nginx.conf  /etc/nginx/conf.d/default.conf
EXPOSE 80

Here is more version information:

enter image description here

Any help would be HIGHLY appreciated. I need to figure this out.


Solution

  • RUN npm run build --prod is executed INSIDE the docker container, and node inside is not in required version.

    Also you clearly states that you want to use node v12 with

    FROM node:12.14-alpine AS builder
    

    so this is why it is "detected" as 12 because this is the node version inside the container. Bump the version. You can use some of images listed here https://hub.docker.com/_/node

    eg

     FROM node:14.20.0-alpine AS builder