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
This commit is contained in:
Alan Orth
2024-09-05 10:22:52 +03:00
parent f3619ff4d8
commit 10df0ac366
2 changed files with 5 additions and 7 deletions

View File

@@ -11,9 +11,7 @@ WORKDIR /app
ADD . /app/ ADD . /app/
EXPOSE 4000 EXPOSE 4000
# We run yarn install with an increased network timeout (5min) to avoid "ESOCKETTIMEDOUT" errors from hub.docker.com RUN npm install
# See, for example https://github.com/yarnpkg/yarn/issues/5540
RUN yarn install --network-timeout 300000
# When running in dev mode, 4GB of memory is required to build & launch the app. # 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. # 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 # 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 # if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
ENV NODE_ENV development ENV NODE_ENV development
CMD yarn serve --host 0.0.0.0 CMD npm run serve -- --host 0.0.0.0

View File

@@ -11,11 +11,11 @@ FROM node:18-alpine AS build
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/* RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
WORKDIR /app WORKDIR /app
COPY package.json yarn.lock ./ COPY package.json package-lock.json ./
RUN yarn install --network-timeout 300000 RUN npm install
ADD . /app/ ADD . /app/
RUN yarn build:prod RUN npm run build:prod
FROM node:18-alpine FROM node:18-alpine
RUN npm install --global pm2 RUN npm install --global pm2