Skip to content

Commit 10df0ac

Browse files
committed
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
1 parent f3619ff commit 10df0ac

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ WORKDIR /app
1111
ADD . /app/
1212
EXPOSE 4000
1313

14-
# We run yarn install with an increased network timeout (5min) to avoid "ESOCKETTIMEDOUT" errors from hub.docker.com
15-
# See, for example https://github.com/yarnpkg/yarn/issues/5540
16-
RUN yarn install --network-timeout 300000
14+
RUN npm install
1715

1816
# When running in dev mode, 4GB of memory is required to build & launch the app.
1917
# 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"
2523
# NOTE: At this time it is only possible to run Docker container in Production mode
2624
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
2725
ENV NODE_ENV development
28-
CMD yarn serve --host 0.0.0.0
26+
CMD npm run serve -- --host 0.0.0.0

Dockerfile.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ FROM node:18-alpine AS build
1111
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
1212

1313
WORKDIR /app
14-
COPY package.json yarn.lock ./
15-
RUN yarn install --network-timeout 300000
14+
COPY package.json package-lock.json ./
15+
RUN npm install
1616

1717
ADD . /app/
18-
RUN yarn build:prod
18+
RUN npm run build:prod
1919

2020
FROM node:18-alpine
2121
RUN npm install --global pm2

0 commit comments

Comments
 (0)