From 10df0ac366852037dcd371426e12a491102f819f Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Thu, 5 Sep 2024 10:22:52 +0300 Subject: [PATCH] Use npm instead of yarn in Dockerfile There is a minor difference in syntax when starting the application with `npm run serve`. We use `--` to make sure npm doesn't try to parse the `--host 0.0.0.0` as an option, allowing it instead to be read by Angular CLI (ng). Also, there is no direct npm equivalent to yarn's --network-timeout option so I will remove it. If we need something similar later we might be able to use these config options: npm config set fetch-retry-mintimeout 300000 npm config set fetch-retry-maxtimeout 300000 --- Dockerfile | 6 ++---- Dockerfile.dist | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8fac7495e1..cd29d762f8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,9 +11,7 @@ WORKDIR /app ADD . /app/ EXPOSE 4000 -# We run yarn install with an increased network timeout (5min) to avoid "ESOCKETTIMEDOUT" errors from hub.docker.com -# See, for example https://github.com/yarnpkg/yarn/issues/5540 -RUN yarn install --network-timeout 300000 +RUN npm install # When running in dev mode, 4GB of memory is required to build & launch the app. # This default setting can be overridden as needed in your shell, via an env file or in docker-compose. @@ -25,4 +23,4 @@ ENV NODE_OPTIONS="--max_old_space_size=4096" # NOTE: At this time it is only possible to run Docker container in Production mode # if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485 ENV NODE_ENV development -CMD yarn serve --host 0.0.0.0 +CMD npm run serve -- --host 0.0.0.0 diff --git a/Dockerfile.dist b/Dockerfile.dist index 4c47b0cb40..cb6e1bbd30 100644 --- a/Dockerfile.dist +++ b/Dockerfile.dist @@ -11,11 +11,11 @@ FROM node:18-alpine AS build RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/* WORKDIR /app -COPY package.json yarn.lock ./ -RUN yarn install --network-timeout 300000 +COPY package.json package-lock.json ./ +RUN npm install ADD . /app/ -RUN yarn build:prod +RUN npm run build:prod FROM node:18-alpine RUN npm install --global pm2