Skip to content

Commit 6ca170f

Browse files
committed
Minor cleanup to Dockerfile. Update to Node v22. Create a staged build and update to "npm ci" (recommended for Docker). Use best practices for ENTRYPOINT vs CMD
1 parent 4065f06 commit 6ca170f

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

Dockerfile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
# This image will be published as dspace/dspace-angular
22
# See https://github.com/DSpace/dspace-angular/tree/main/docker for usage details
33

4-
FROM docker.io/node:20-alpine
4+
FROM docker.io/node:22-alpine
55

66
# Ensure Python and other build tools are available
77
# These are needed to install some node modules, especially on linux/arm64
88
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
99

1010
WORKDIR /app
11-
ADD . /app/
12-
EXPOSE 4000
1311

14-
RUN npm install
12+
# Copy over package files first, so this layer will only be rebuilt if those files change.
13+
COPY package.json package-lock.json ./
14+
# NOTE: "ci" = clean install from package files
15+
RUN npm ci
16+
17+
# Add the rest of the source code
18+
COPY . /app/
1519

1620
# When running in dev mode, 4GB of memory is required to build & launch the app.
1721
# This default setting can be overridden as needed in your shell, via an env file or in docker-compose.
1822
# See Docker environment var precedence: https://docs.docker.com/compose/environment-variables/envvars-precedence/
1923
ENV NODE_OPTIONS="--max_old_space_size=4096"
2024

2125
# On startup, run in DEVELOPMENT mode (this defaults to live reloading enabled, etc).
22-
# Listen / accept connections from all IP addresses.
23-
# NOTE: At this time it is only possible to run Docker container in Production mode
24-
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
2526
ENV NODE_ENV=development
26-
CMD npm run serve -- --host 0.0.0.0
27+
28+
EXPOSE 4000
29+
30+
# On startup, run this command to start application in dev mode
31+
ENTRYPOINT [ "npm", "run", "serve" ]
32+
# By default set host to 0.0.0.0 to listen/accept connections from all IP addresses.
33+
CMD ["--", "--host 0.0.0.0"]

0 commit comments

Comments
 (0)