Skip to content

Commit 7907a8c

Browse files
committed
[DSC-2193] test Dockerfile.dist
1 parent 313b431 commit 7907a8c

1 file changed

Lines changed: 23 additions & 14 deletions

File tree

Dockerfile.dist

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,40 @@
1+
# syntax=docker/dockerfile:1.7-labs
2+
13
# 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
35

46
# Test build:
57
# docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-8_x-dist .
68

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
815

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/
1217

1318
WORKDIR /app
14-
COPY package.json yarn.lock ./
15-
RUN yarn install --network-timeout 300000
1619

17-
ADD . /app/
20+
# Build Angular app
1821
RUN yarn build:prod
1922

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
2225

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
2628

2729
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+
2836
USER node
2937
ENV NODE_ENV=production
3038
EXPOSE 4000
31-
CMD pm2-runtime start dspace-ui.json --json
39+
40+
CMD ["pm2-runtime", "start", "dspace-ui.json", "--json"]

0 commit comments

Comments
 (0)