Skip to content

Commit e49fa07

Browse files
Merged dspace-cris-2024_02_x into task/dspace-cris-2024_02_x/DSC-2385-deleting-of-dspace-objects
2 parents 8d22814 + 79abfe2 commit e49fa07

File tree

69 files changed

+594
-251
lines changed

Some content is hidden

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

69 files changed

+594
-251
lines changed

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=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:-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-angular-dependencies:2024_02_x .
3+
4+
# Angular 17 + Node 22 optimized Dockerfile
5+
ARG NODE_VERSION=22
6+
ARG DSPACE_VERSION=2024_02_X
7+
ARG DOCKER_REGISTRY=docker.io
8+
9+
FROM ${DOCKER_REGISTRY:-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 --network-timeout 300000

Dockerfile.dist

Lines changed: 22 additions & 13 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
24
# See https://github.com/DSpace/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=22
11+
ARG DSPACE_VERSION=2024_02_x
12+
ARG DOCKER_REGISTRY=docker.io
13+
14+
FROM ${DOCKER_REGISTRY:-docker.io}/4science/dspace-cris-angular-dependencies:${DSPACE_VERSION:-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_REGISTRY:-docker.io}/node:${NODE_VERSION-22}-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"]

bitbucket-pipelines.yml

Lines changed: 194 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,216 @@ options:
33

44
definitions:
55
caches:
6-
node-cris8: ./node_modules
6+
cypress-2024-02-x: ~/.cache/Cypress
7+
node-2024-02-x: ./node_modules
78

89
steps:
10+
- step: &preliminary-operation
11+
name: Preliminary Operation
12+
image: alpine/git:latest
13+
script:
14+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
15+
- export BRANCH_NAME=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1; else if(NF==2)val=$1"--"$2; else if(NF==3)val=$2; else if(NF==4)val=$2"--"$3; print tolower(val)}')
16+
- echo "Using commit hash $HASH_COMMIT"
17+
- git config --global user.email "${BB_USER}"
18+
- git config --global user.name "${BB_EMAIL}"
19+
- git clone https://x-token-auth:${E2ERUNNERS_ACCESS_TOKEN}@${E2E_VALUES_REPO}
20+
- cd e2erunners-values
21+
- sed "s#HASH_COMMIT#${HASH_COMMIT}#g" TPL >> ${HASH_COMMIT}
22+
- sed -i "s#BRANCH_NAME#${BRANCH_NAME}#g" TPL ${HASH_COMMIT}
23+
- git add ${HASH_COMMIT}
24+
- git commit -m "Add configuration for e2e-${HASH_COMMIT}"
25+
- git push
26+
- cd ..
27+
- git clone https://x-token-auth:${HELM_CHARTS_ACCESS_TOKEN}@${HELM_CHARTS_REPO}
28+
- cd helm-charts
29+
- PATH_VALUE=" e2e-$HASH_COMMIT"
30+
- printf " - name:%s\n" "$PATH_VALUE" >> ${E2E_VALUES}
31+
- git add e2e-ingress/values.yaml
32+
- git commit -m "Add ${HASH_COMMIT} to e2e-ingress values"
33+
- git push
34+
- cd ..
35+
36+
- step: &preliminary-operation-backend
37+
name: Preliminary Operation
38+
image: alpine/git:latest
39+
script:
40+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
41+
- export BRANCH_NAME=$(echo "$BITBUCKET_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's|/|--|g')
42+
- echo "Using commit hash $HASH_COMMIT"
43+
- git config --global user.email "${BB_USER}"
44+
- git config --global user.name "${BB_EMAIL}"
45+
- git clone https://x-token-auth:${E2ERUNNERS_ACCESS_TOKEN}@${E2E_VALUES_REPO}
46+
- cd e2erunners-values
47+
- sed "s#HASH_COMMIT#${HASH_COMMIT}#g" TPL >> ${HASH_COMMIT}
48+
- sed -i "s#BRANCH_NAME#${BRANCH_NAME}#g" TPL ${HASH_COMMIT}
49+
- git add ${HASH_COMMIT}
50+
- git commit -m "Add configuration for e2e-${HASH_COMMIT}"
51+
- git push
52+
- cd ..
53+
- git clone https://x-token-auth:${HELM_CHARTS_ACCESS_TOKEN}@${HELM_CHARTS_REPO}
54+
- cd helm-charts
55+
- PATH_VALUE=" e2e-$HASH_COMMIT"
56+
- printf " - name:%s\n" "$PATH_VALUE" >> ${E2E_VALUES}
57+
- git add e2e-ingress/values.yaml
58+
- git commit -m "Add ${HASH_COMMIT} to e2e-ingress values"
59+
- git push
60+
- cd ..
61+
62+
- step: &angular-build
63+
name: angular-build
64+
image:
65+
name: cypress/browsers:node-18.20.3-chrome-125.0.6422.141-1-ff-126.0.1-edge-125.0.2535.85-1
66+
run-as-user: 1000
67+
size: 4x
68+
caches:
69+
- node-2024-02-x
70+
script:
71+
- yarn install --frozen-lockfile
72+
- yarn run build:prod:ci
73+
- yarn run build:mirador
74+
artifacts:
75+
- node_modules/**
76+
- dist/**
77+
978
- step: &unittest-code-checks
1079
name: test-code-checks
1180
image:
1281
name: cypress/browsers:node-18.20.3-chrome-125.0.6422.141-1-ff-126.0.1-edge-125.0.2535.85-1
1382
run-as-user: 1000
1483
size: 4x
1584
caches:
16-
- node-cris8
85+
- node-2024-02-x
1786
script:
18-
- yarn install --frozen-lockfile
19-
- yarn run lint --quiet
87+
- yarn build:lint
88+
- npm run ng-high-memory -- lint --quiet
2089
- yarn run check-circ-deps
21-
- yarn run build:prod:ci
2290
- yarn run test:headless
91+
artifacts:
92+
- .next/**
93+
- .cache/**
94+
- ~/.cache/Cypress
95+
96+
- step: &run-e2e-tests
97+
name: Run E2E test
98+
image:
99+
name: cypress/browsers:node-18.20.3-chrome-125.0.6422.141-1-ff-126.0.1-edge-125.0.2535.85-1
100+
run-as-user: 0
101+
size: 4x
102+
services:
103+
- docker
104+
caches:
105+
- node-2024-02-x
106+
- cypress-2024-02-x
107+
script:
108+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
109+
- echo "Running tests for commit $HASH_COMMIT"
110+
- export DSPACE_REST_HOST=${E2E_RUNNER_HOST}
111+
- export DSPACE_REST_PORT=443
112+
- export DSPACE_REST_NAMESPACE=/e2e-${HASH_COMMIT}/server
113+
- echo "Configured REST endpoint at https://$DSPACE_REST_HOST$DSPACE_REST_NAMESPACE"
114+
- export DSPACE_REST_SSL=true
115+
- export DSPACE_UI_HOST=127.0.0.1
116+
- export DSPACE_UI_PORT=4000
117+
- export DSPACE_CACHE_SERVERSIDE_BOTCACHE_MAX=0
118+
- export DSPACE_CACHE_SERVERSIDE_ANONYMOUSCACHE_MAX=0
119+
- export CYPRESS_BASE_URL=http://127.0.0.1:4000
120+
- export CYPRESS_CACHE_FOLDER=~/.cache/Cypress
121+
- export CHROME_FLAGS="--no-sandbox --disable-dev-shm-usage --disable-gpu"
122+
- export NODE_OPTIONS="--max-old-space-size=4096"
123+
- npx cypress install
124+
- yarn serve:ssr &
125+
- echo "Waiting for server to start..."
126+
- sleep 10
127+
- echo "Running Cypress tests..."
128+
- yarn cypress:run --env chromeFlags="$CHROME_FLAGS"
129+
- echo "Test execution completed"
130+
artifacts:
131+
- cypress/screenshots/**
132+
- cypress/videos/**
133+
134+
- step: &build-and-push
135+
name: Build and Push Docker Image to ECR
136+
size: 4x
137+
image: atlassian/default-image:3
138+
services:
139+
- docker
140+
script:
141+
- echo "Copying dist to Docker context"
142+
- mkdir -p build-context
143+
- cp -r dist config build-context/
144+
- cp Dockerfile.build build-context/Dockerfile
145+
- cd build-context
146+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
147+
- export BRANCH_NAME=$(echo "$BITBUCKET_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's|/|--|g')
148+
- docker build -t dspace-angular:${BRANCH_NAME}-${HASH_COMMIT} -t dspace-angular:${BRANCH_NAME}-latest .
149+
- pipe: atlassian/aws-ecr-push-image:2.5.0
150+
variables:
151+
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
152+
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
153+
AWS_DEFAULT_REGION: $AWS_REGION
154+
IMAGE_NAME: dspace-angular
155+
TAGS: "${BRANCH_NAME}-${HASH_COMMIT} ${BRANCH_NAME}-latest"
156+
157+
- step: &deploy-on-dev
158+
name: Deploy on Development environment
159+
image: alpine/git:latest
160+
script:
161+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
162+
- export BRANCH_NAME=$(echo "$BITBUCKET_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's|/|--|g')
163+
- export BRANCH_FILE=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
164+
- git clone https://x-token-auth:${DSPACE_VALUES_ACCESS_TOKEN}@${DSPACE_VALUES_REPO}
165+
- cd dspace-values
166+
- '[ -f "dev/${BRANCH_FILE}" ] && sed -i "/^angular:/,/^[^ ]/s/\(tag: \).*/\1${BRANCH_NAME}-${HASH_COMMIT}/" "dev/${BRANCH_FILE}"'
167+
- git config --global user.email "[email protected]"
168+
- git config --global user.name "CI Bot"
169+
- git commit -am "Update TAG with ${BRANCH_NAME}-${HASH_COMMIT}"
170+
- git push
171+
172+
- step: &deploy-on-staging
173+
name: Deploy on Staging environment
174+
image: alpine/git:latest
175+
script:
176+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
177+
- export BRANCH_NAME=$(echo "$BITBUCKET_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's|/|--|g')
178+
- export BRANCH_FILE=$(echo "$BITBUCKET_BRANCH" | awk -F'/' '{if(NF==1)val=$1;else if(NF==2)val=$2;else if(NF==3)val=$2;else val=$3;gsub(/_/, "-", val);print tolower(val)}')
179+
- git clone https://x-token-auth:${DSPACE_VALUES_ACCESS_TOKEN}@${DSPACE_VALUES_REPO}
180+
- cd dspace-values
181+
- '[ -f "staging/${BRANCH_FILE}" ] && sed -i "/^angular:/,/^[^ ]/s/\(tag: \).*/\1${BRANCH_NAME}-${HASH_COMMIT}/" "staging/${BRANCH_FILE}"'
182+
- git config --global user.email "${BB_EMAIL}"
183+
- git config --global user.name "${BB_USER}"
184+
- git commit -am "Update TAG with ${BRANCH_NAME}-${HASH_COMMIT}"
185+
- git push
23186

24187
pipelines:
188+
custom:
189+
e2e-on-custom-backend:
190+
- step: *preliminary-operation-backend
191+
- step: *angular-build
192+
- parallel: &parallel-run-tests
193+
- step: *unittest-code-checks
194+
- step: *run-e2e-tests
195+
deploy-on-dev:
196+
- step: *angular-build
197+
- step: *build-and-push
198+
- step: *deploy-on-dev
25199
branches:
26200
'dspace-cris-2024_02_x':
27-
- step: *unittest-code-checks
201+
- step: *preliminary-operation
202+
- step: *angular-build
203+
- parallel: *parallel-run-tests
204+
- step: *build-and-push
205+
- step: *deploy-on-dev
206+
- step: *deploy-on-staging
28207
'prod/**':
29-
- step: *unittest-code-checks
208+
- step: *preliminary-operation
209+
- step: *angular-build
210+
- parallel: *parallel-run-tests
211+
- step: *build-and-push
212+
- step: *deploy-on-dev
213+
- step: *deploy-on-staging
30214
pull-requests:
31215
'**':
32-
- step: *unittest-code-checks
216+
- step: *preliminary-operation
217+
- step: *angular-build
218+
- parallel: *parallel-run-tests

cypress.config.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,25 @@ export default defineConfig({
1818
// (This is the data set used in our CI environment)
1919

2020
// Admin account used for administrative tests
21-
DSPACE_TEST_ADMIN_USER: 'dspacedemo+admin@gmail.com',
21+
DSPACE_TEST_ADMIN_USER: 'admin@admin.com',
2222
DSPACE_TEST_ADMIN_USER_UUID: '335647b6-8a52-4ecb-a8c1-7ebabb199bda',
23-
DSPACE_TEST_ADMIN_PASSWORD: 'dspace',
23+
DSPACE_TEST_ADMIN_PASSWORD: 'admin',
2424
// Community/collection/publication used for view/edit tests
25-
DSPACE_TEST_COMMUNITY: '0958c910-2037-42a9-81c7-dca80e3892b4',
26-
DSPACE_TEST_COLLECTION: '282164f5-d325-4740-8dd1-fa4d6d3e7200',
27-
DSPACE_TEST_ENTITY_PUBLICATION: '6160810f-1e53-40db-81ef-f6621a727398',
25+
DSPACE_TEST_COMMUNITY: 'a30b75e4-1682-4b4d-85fd-a47fc78dbcf6',
26+
DSPACE_TEST_COLLECTION: 'caf04bfa-b2f6-40d3-90d2-aa0b86d92f8d',
27+
DSPACE_TEST_ENTITY_PUBLICATION: '9d1efbce-4d55-446c-ac70-0ba8998d04d2',
2828
// Search term (should return results) used in search tests
2929
DSPACE_TEST_SEARCH_TERM: 'test',
3030
// Main Collection used for submission tests. Should be able to accept normal Item objects
31-
DSPACE_TEST_SUBMIT_COLLECTION_NAME: 'Sample Collection',
32-
DSPACE_TEST_SUBMIT_COLLECTION_UUID: '9d8334e9-25d3-4a67-9cea-3dffdef80144',
31+
DSPACE_TEST_SUBMIT_COLLECTION_NAME: 'Equipments',
32+
DSPACE_TEST_SUBMIT_COLLECTION_UUID: 'c1da6a21-451f-430d-ad28-0f16e5b38fa0',
3333
// Collection used for Person entity submission tests. MUST be configured with EntityType=Person.
34-
DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME: 'People',
34+
DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME: 'Persons',
3535
// Account used to test basic submission process
36-
DSPACE_TEST_SUBMIT_USER: 'dspacedemo+submit@gmail.com',
37-
DSPACE_TEST_SUBMIT_USER_PASSWORD: 'dspace',
36+
DSPACE_TEST_SUBMIT_USER: 'admin@admin.com',
37+
DSPACE_TEST_SUBMIT_USER_PASSWORD: 'admin',
3838
// Administrator users group
39-
DSPACE_ADMINISTRATOR_GROUP: 'e59f5659-bff9-451e-b28f-439e7bd467e4'
39+
DSPACE_ADMINISTRATOR_GROUP: 'f8c90336-34c1-4ad6-ab63-ba4b9357f087'
4040
},
4141
e2e: {
4242
// Setup our plugins for e2e tests
@@ -62,4 +62,5 @@ export default defineConfig({
6262
]
6363
},
6464
defaultCommandTimeout: 10000,
65+
requestTimeout: 20000,
6566
});

0 commit comments

Comments
 (0)