Reputation: 51
I tried many ways to solve this problem, but it's not working. I have an angular app, I created a Dockerfile with the code below:
FROM node:latest AS ng-builder
RUN mkdir -p /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN $(npm bin)/ng build --prod
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
COPY --from=ng-builder /app/dist/sca-front /usr/share/nginx/html
EXPOSE 80
My application works well when running "ng s". But when I create an image on Docker, it doesn't work. I have no proxy, no vpn, a good internet connection...
These errors/warnings are shown:
npm notice
npm notice New patch version of npm available! 7.0.3 -> 7.0.7
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v7.0.7>
npm notice Run `npm install -g [email protected]` to update!
npm notice
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! request to https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz failed, reason: Socket timeout
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-11-01T01_24_40_819Z-debug.log
I tried call "RUN npm RUN npm install -g [email protected]" because of version of angular...but it looks like an timeout. I tried change the npm version on docker...but it doesn't work.
I tried the dockerfile in a new/small project, it's working. But in a bigger project...
Upvotes: 4
Views: 2480
Reputation: 21
I experienced an error similar to this while trying to create a container on Docker for my react app.
I solved it using the node:14-apline
for the base image and installed npm@latest
just before installing packages.
Note: You can decide to install npm@7
instead.
FROM node:14-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install npm@latest
RUN npm install
COPY . ./
CMD ["npm","run","start"]
https://github.com/npm/cli/issues/2031#issuecomment-715935308
Upvotes: 2