|
| 1 | +# syntax=docker/dockerfile:1.7-labs |
| 2 | + |
1 | 3 | # This image will be published as dspace/dspace-angular:$DSPACE_VERSION-dist |
2 | | -# See https://github.com/DSpace/dspace-angular/tree/main/docker for usage details |
| 4 | +# See https://github.com/4science/dspace-angular/tree/main/docker for usage details |
3 | 5 |
|
4 | 6 | # Test build: |
5 | 7 | # docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-8_x-dist . |
6 | 8 |
|
7 | | -FROM docker.io/node:18-alpine AS build |
| 9 | +# Angular 17 + Node 22 optimized Dockerfile |
| 10 | +ARG NODE_VERSION=20 |
| 11 | +ARG DSPACE_VERSION=dspace-cris-2024_02_x |
| 12 | +ARG DOCKER_REGISTRY=docker.io |
| 13 | + |
| 14 | +FROM ${DOCKER_REGISTRY:-docker.io}/4science/dspace-cris-dependencies:${DSPACE_VERSION:-dspace-cris-2024_02_x} AS build |
8 | 15 |
|
9 | | -# Ensure Python and other build tools are available |
10 | | -# These are needed to install some node modules, especially on linux/arm64 |
11 | | -RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/* |
| 16 | +COPY --parents src/** config/** webpack/** docker/dspace-ui.json angular.json server.ts startup-message.ts tsconfig.json tsconfig.app.json tsconfig.server.json tsconfig.spec.json tsconfig.ts-node.json typedoc.json /app/ |
12 | 17 |
|
13 | 18 | WORKDIR /app |
14 | | -COPY package.json yarn.lock ./ |
15 | | -RUN yarn install --network-timeout 300000 |
16 | 19 |
|
17 | | -ADD . /app/ |
| 20 | +# Build Angular app |
18 | 21 | RUN yarn build:prod |
19 | 22 |
|
20 | | -FROM node:18-alpine |
21 | | -RUN npm install --global pm2 |
| 23 | +# ---- Production image ---- |
| 24 | +FROM docker.io/node:${NODE_VERSION-20}-alpine AS prod |
22 | 25 |
|
23 | | -COPY --chown=node:node --from=build /app/dist /app/dist |
24 | | -COPY --chown=node:node config /app/config |
25 | | -COPY --chown=node:node docker/dspace-ui.json /app/dspace-ui.json |
| 26 | +# Install pm2 globally and clean npm cache |
| 27 | +RUN npm install --global pm2 && npm cache clean --force |
26 | 28 |
|
27 | 29 | WORKDIR /app |
| 30 | + |
| 31 | +# Only copy built files and config |
| 32 | +COPY --chown=node:node --from=build /app/dist /app/dist |
| 33 | +COPY --chown=node:node --from=build /app/config /app/config |
| 34 | +COPY --chown=node:node --from=build /app/docker/dspace-ui.json /app/dspace-ui.json |
| 35 | + |
28 | 36 | USER node |
29 | 37 | ENV NODE_ENV=production |
30 | 38 | EXPOSE 4000 |
31 | | -CMD pm2-runtime start dspace-ui.json --json |
| 39 | + |
| 40 | +CMD ["pm2-runtime", "start", "dspace-ui.json", "--json"] |
0 commit comments