Skip to content

Commit 6f741aa

Browse files
committed
Merged dspace-cris-2024_02_x into task/dspace-cris-2024_02_x/DSC-2281
2 parents a76fa29 + 7c3ca26 commit 6f741aa

441 files changed

Lines changed: 148129 additions & 37640 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"eslint-plugin-rxjs",
1313
"eslint-plugin-simple-import-sort",
1414
"eslint-plugin-import-newlines",
15-
"eslint-plugin-jsonc",
1615
"dspace-angular-ts",
1716
"dspace-angular-html"
1817
],
@@ -302,10 +301,13 @@
302301
"*.json5"
303302
],
304303
"extends": [
305-
"plugin:jsonc/recommended-with-jsonc"
304+
"plugin:jsonc/recommended-with-json5"
306305
],
307306
"rules": {
308-
"no-irregular-whitespace": "error",
307+
// The ESLint core no-irregular-whitespace rule doesn't work well in JSON
308+
// See: https://ota-meshi.github.io/eslint-plugin-jsonc/rules/no-irregular-whitespace.html
309+
"no-irregular-whitespace": "off",
310+
"jsonc/no-irregular-whitespace": "error",
309311
"no-trailing-spaces": "error",
310312
"jsonc/comma-dangle": [
311313
"error",

.github/workflows/build.yml

Lines changed: 103 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
DSPACE_CACHE_SERVERSIDE_ANONYMOUSCACHE_MAX: 0
3030
# Tell Cypress to run e2e tests using the same UI URL
3131
CYPRESS_BASE_URL: http://127.0.0.1:4000
32+
# Disable the cookie consent banner in e2e tests to avoid errors because of elements hidden by it
33+
DSPACE_INFO_ENABLECOOKIECONSENTPOPUP: false
3234
# When Chrome version is specified, we pin to a specific version of Chrome
3335
# Comment this out to use the latest release
3436
#CHROME_VERSION: "116.0.5845.187-1"
@@ -191,11 +193,107 @@ jobs:
191193
# If it does, then SSR is working, as this tag is created by our MetadataService.
192194
# This step also prints entire HTML of homepage for easier debugging if grep fails.
193195
# TODO: enable this step once we have a CRIS back end to test against
194-
# - name: Verify SSR (server-side rendering)
195-
# run: |
196-
# result=$(wget -O- -q http://127.0.0.1:4000/home)
197-
# echo "$result"
198-
# echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep DSpace
196+
# - name: Verify SSR (server-side rendering) on Homepage
197+
# run: |
198+
# result=$(wget -O- -q http://127.0.0.1:4000/home)
199+
# echo "$result"
200+
# echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep DSpace
201+
202+
# Get a specific community in our test data and verify that the "<h1>" tag includes "Publications" (the community name).
203+
# If it does, then SSR is working.
204+
- name: Verify SSR on a Community page
205+
run: |
206+
result=$(wget -O- -q http://127.0.0.1:4000/communities/a30b75e4-1682-4b4d-85fd-a47fc78dbcf6)
207+
echo "$result"
208+
echo "$result" | grep -oE "<h1 [^>]*>[^><]*</h1>" | grep "CRIS Community"
209+
210+
# Get a specific collection in our test data and verify that the "<h1>" tag includes "Publications" (the collection name).
211+
# If it does, then SSR is working.
212+
- name: Verify SSR on a Collection page
213+
run: |
214+
result=$(wget -O- -q http://127.0.0.1:4000/collections/caf04bfa-b2f6-40d3-90d2-aa0b86d92f8d)
215+
echo "$result"
216+
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Publications"
217+
218+
# Get a specific publication in our test data and verify that the <meta name="title"> tag includes
219+
# the title of this publication. If it does, then SSR is working.
220+
- name: Verify SSR on a Publication page
221+
run: |
222+
result=$(wget -O- -q http://127.0.0.1:4000/entities/publication/1df533fd-5385-4820-babd-b5fabdb82101)
223+
echo "$result"
224+
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "test publication with pdf version 1"
225+
226+
# Get a specific person in our test data and verify that the <meta name="title"> tag includes
227+
# the name of the person. If it does, then SSR is working.
228+
- name: Verify SSR on a Person page
229+
run: |
230+
result=$(wget -O- -q http://127.0.0.1:4000/entities/person/98cea993-d448-4200-99d5-f6fab8967bf8)
231+
echo "$result"
232+
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Submitter Dspace"
233+
234+
# Get a specific project in our test data and verify that the <meta name="title"> tag includes
235+
# the name of the project. If it does, then SSR is working.
236+
- name: Verify SSR on a Project page
237+
run: |
238+
result=$(wget -O- -q http://127.0.0.1:4000/entities/project/1e3451e4-60d7-46a8-962e-5b94b62c63ff)
239+
echo "$result"
240+
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Test DSC-1819"
241+
242+
# Get a specific orgunit in our test data and verify that the <meta name="title"> tag includes
243+
# the name of the orgunit. If it does, then SSR is working.
244+
- name: Verify SSR on an OrgUnit page
245+
run: |
246+
result=$(wget -O- -q http://127.0.0.1:4000/entities/orgunit/6d4abaee-eedb-458d-a29b-35db82037dfa)
247+
echo "$result"
248+
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "4Science"
249+
250+
# Get a specific journal in our test data and verify that the <meta name="title"> tag includes
251+
# the name of the journal. If it does, then SSR is working.
252+
- name: Verify SSR on a Journal page
253+
run: |
254+
result=$(wget -O- -q http://127.0.0.1:4000/entities/journal/f05c4530-b1b8-4459-a048-ea1c60089a1e)
255+
echo "$result"
256+
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "Journal 4S"
257+
258+
# Get a specific funding in our test data and verify that the <meta name="title"> tag includes
259+
# the name of the funding. If it does, then SSR is working.
260+
- name: Verify SSR on a Funding page
261+
run: |
262+
result=$(wget -O- -q http://127.0.0.1:4000/entities/funding/640d35ba-6172-44c0-9e11-bf5da417cdc8)
263+
echo "$result"
264+
echo "$result" | grep -oE "<meta name=\"title\" [^>]*>" | grep "test funding"
265+
266+
267+
# Verify 301 Handle redirect behavior
268+
# Note: /handle/123456789/260 is the same test Publication used by our e2e tests
269+
- name: Verify 301 redirect from '/handle' URLs
270+
run: |
271+
result=$(wget --server-response --quiet http://127.0.0.1:4000/handle/123456789/71 2>&1 | head -1 | awk '{print $2}')
272+
echo "$result"
273+
[[ "$result" -eq "301" ]]
274+
275+
# Verify 403 error code behavior
276+
- name: Verify 403 error code from '/403'
277+
run: |
278+
result=$(wget --server-response --quiet http://127.0.0.1:4000/403 2>&1 | head -1 | awk '{print $2}')
279+
echo "$result"
280+
[[ "$result" -eq "403" ]]
281+
282+
# Verify 404 error code behavior
283+
- name: Verify 404 error code from '/404' and on invalid pages
284+
run: |
285+
result=$(wget --server-response --quiet http://127.0.0.1:4000/404 2>&1 | head -1 | awk '{print $2}')
286+
echo "$result"
287+
result2=$(wget --server-response --quiet http://127.0.0.1:4000/invalidurl 2>&1 | head -1 | awk '{print $2}')
288+
echo "$result2"
289+
[[ "$result" -eq "404" && "$result2" -eq "404" ]]
290+
291+
# Verify 500 error code behavior
292+
- name: Verify 500 error code from '/500'
293+
run: |
294+
result=$(wget --server-response --quiet http://127.0.0.1:4000/500 2>&1 | head -1 | awk '{print $2}')
295+
echo "$result"
296+
[[ "$result" -eq "500" ]]
199297
200298
- name: Stop running app
201299
run: kill -9 $(lsof -t -i:4000)

.github/workflows/docker.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,44 +9,66 @@ name: Docker images
99
on:
1010
push:
1111
branches:
12-
- main
13-
- 'dspace-**'
12+
- main-cris
13+
- 'dspace-cris-*_02_x'
1414
tags:
15-
- 'dspace-**'
15+
- 'dspace-cris-**'
1616
pull_request:
1717

1818
permissions:
1919
contents: read # to fetch code (actions/checkout)
2020
packages: write # to write images to GitHub Container Registry (GHCR)
2121

2222
jobs:
23+
24+
####################################################
25+
# Build/Push the '4science/dspace-cris-dependencies' image.
26+
# This image is used by all other DSpace build jobs.
27+
####################################################
28+
dspace-cris-angular-dependencies:
29+
# Ensure this job never runs on forked repos. It's only executed for '4science/dspace'
30+
if: github.repository == '4science/dspace-angular'
31+
# Use the reusable-docker-build.yml script from DSpace/DSpace repo to build our Docker image
32+
uses: 4science/DSpace/.github/workflows/reusable-docker-build.yml@dspace-cris-2024_02_x
33+
with:
34+
build_id: dspace-cris-angular-dependencies
35+
image_name: 4science/dspace-cris-angular-dependencies
36+
dockerfile_path: ./Dockerfile.dependencies
37+
secrets:
38+
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
39+
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
40+
41+
2342
#############################################################
24-
# Build/Push the 'dspace/dspace-angular' image
43+
# Build/Push the '4science/dspace-cris-angular' image
2544
#############################################################
2645
dspace-angular:
2746
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
28-
if: github.repository == 'dspace/dspace-angular'
47+
if: github.repository == '4science/dspace-angular'
2948
# Use the reusable-docker-build.yml script from DSpace/DSpace repo to build our Docker image
30-
uses: DSpace/DSpace/.github/workflows/reusable-docker-build.yml@main
49+
uses: 4science/DSpace/.github/workflows/reusable-docker-build.yml@dspace-cris-2024_02_x
50+
needs: dspace-cris-angular-dependencies
3151
with:
32-
build_id: dspace-angular-dev
33-
image_name: dspace/dspace-angular
52+
build_id: dspace-cris-angular-dev
53+
image_name: 4science/dspace-cris-angular
3454
dockerfile_path: ./Dockerfile
3555
secrets:
3656
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
3757
DOCKER_ACCESS_TOKEN: ${{ secrets.DOCKER_ACCESS_TOKEN }}
3858

3959
#############################################################
40-
# Build/Push the 'dspace/dspace-angular' image ('-dist' tag)
60+
# Build/Push the '4science/dspace-cris-angular' image ('-dist' tag)
4161
#############################################################
4262
dspace-angular-dist:
4363
# Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular'
44-
if: github.repository == 'dspace/dspace-angular'
64+
if: github.repository == '4science/dspace-angular'
4565
# Use the reusable-docker-build.yml script from DSpace/DSpace repo to build our Docker image
46-
uses: DSpace/DSpace/.github/workflows/reusable-docker-build.yml@main
66+
uses: 4science/DSpace/.github/workflows/reusable-docker-build.yml@dspace-cris-2024_02_x
67+
# Must run after 'dspace-dependencies' job above
68+
needs: dspace-cris-angular-dependencies
4769
with:
48-
build_id: dspace-angular-dist
49-
image_name: dspace/dspace-angular
70+
build_id: dspace-cris-angular-dist
71+
image_name: 4science/dspace-cris-angular
5072
dockerfile_path: ./Dockerfile.dist
5173
# As this is a "dist" image, its tags are all suffixed with "-dist". Otherwise, it uses the same
5274
# tagging logic as the primary 'dspace/dspace-angular' image above.

Dockerfile

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
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:18-alpine
4+
ARG NODE_VERSION=22
5+
ARG DSPACE_VERSION=dspace-cris-2024_02_x
6+
ARG DOCKER_REGISTRY=docker.io
57

6-
# Ensure Python and other build tools are available
7-
# These are needed to install some node modules, especially on linux/arm64
8-
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
8+
FROM ${DOCKER_REGISTRY:-docker.io}/4science/dspace-cris-angular-dependencies:${DSPACE_VERSION:-dspace-cris-2024_02_x} AS dev
99

1010
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
17-
1814
# When running in dev mode, 4GB of memory is required to build & launch the app.
1915
# This default setting can be overridden as needed in your shell, via an env file or in docker-compose.
2016
# See Docker environment var precedence: https://docs.docker.com/compose/environment-variables/envvars-precedence/
@@ -25,4 +21,4 @@ ENV NODE_OPTIONS="--max_old_space_size=4096"
2521
# NOTE: At this time it is only possible to run Docker container in Production mode
2622
# if you have a public URL. See https://github.com/DSpace/dspace-angular/issues/1485
2723
ENV NODE_ENV=development
28-
CMD yarn serve --host 0.0.0.0
24+
CMD ["yarn", "serve", "--host", "0.0.0.0"]

Dockerfile.build

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:20-alpine AS runtime
2+
3+
ENV NODE_ENV=production \
4+
NODE_OPTIONS="--max_old_space_size=4096"
5+
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*
6+
RUN mkdir -p /app/source/config
7+
8+
WORKDIR /app/source
9+
COPY dist/ ./dist
10+
RUN ln -s /data/config.prod.yml /app/source/config/config.prod.yml || true
11+
12+
RUN adduser -D -h /home/dspace -s /bin/bash dspace
13+
RUN chown -R dspace:dspace /app/source/
14+
15+
USER dspace
16+
17+
CMD ["node", "dist/server/main"]

Dockerfile.dependencies

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Test build:
2+
# docker build -f Dockerfile.dependencies -t 4science/dspace-cris-angular-dependencies:dspace-cris-2024_02_x .
3+
4+
# Angular 17 + Node 22 optimized Dockerfile
5+
ARG NODE_VERSION=22
6+
ARG DSPACE_VERSION=dspace-cris-2024_02_x
7+
ARG DOCKER_REGISTRY=docker.io
8+
9+
FROM docker.io/node:${NODE_VERSION-22}-alpine AS dependencies
10+
11+
# Install build dependencies
12+
RUN apk add --no-cache python3 make g++
13+
14+
WORKDIR /app
15+
16+
# Install dependencies (use npm ci if you have package-lock.json)
17+
COPY package.json yarn.lock ./
18+
RUN yarn install --frozen-lockfile --network-timeout 300000

Dockerfile.dist

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
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:
5-
# docker build -f Dockerfile.dist -t dspace/dspace-angular:dspace-8_x-dist .
7+
# docker build -f Dockerfile.dist -t 4science/dspace-angular:dspace-cris-2024_02_x-dist .
8+
9+
# Angular 17 + Node 22 optimized Dockerfile
10+
ARG NODE_VERSION=22
11+
ARG DSPACE_VERSION=dspace-cris-2024_02_x
12+
ARG DOCKER_REGISTRY=docker.io
613

7-
FROM docker.io/node:18-alpine AS build
14+
FROM ${DOCKER_REGISTRY:-docker.io}/4science/dspace-cris-angular-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 . /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
22+
RUN yarn build:mirador
1923

20-
FROM node:18-alpine
21-
RUN npm install --global pm2
24+
# ---- Production image ----
25+
FROM docker.io/node:${NODE_VERSION-22}-alpine AS prod
2226

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
27+
# Install pm2 globally and clean npm cache
28+
RUN npm install --global pm2 && npm cache clean --force
2629

2730
WORKDIR /app
31+
32+
# Only copy built files and config
33+
COPY --chown=node:node --from=build /app/dist /app/dist
34+
COPY --chown=node:node --from=build /app/config /app/config
35+
COPY --chown=node:node --from=build /app/docker/dspace-ui.json /app/dspace-ui.json
36+
2837
USER node
2938
ENV NODE_ENV=production
3039
EXPOSE 4000
31-
CMD pm2-runtime start dspace-ui.json --json
40+
41+
CMD ["pm2-runtime", "start", "dspace-ui.json", "--json"]

0 commit comments

Comments
 (0)