Skip to content

Commit 75caf76

Browse files
Merged dspace-cris-2024_02_x into task/dspace-cris-2024_02_x/DSC-2206
2 parents fe99b0f + aaea642 commit 75caf76

49 files changed

Lines changed: 692 additions & 257 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.

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: 228 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,250 @@ 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}" || echo "No changes to 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" || echo "No changes to commit"
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}" || echo "No changes to 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" || echo "No changes to commit"
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}" && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" "dev/${BRANCH_FILE}"'
167+
- git config --global user.email "${BB_EMAIL}"
168+
- git config --global user.name "${BB_USER}"
169+
- git commit -am "Update TAG with ${BRANCH_NAME}-${HASH_COMMIT}" || echo "No changes to 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}" && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" "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}" || echo "No changes to commit"
185+
- git push
186+
187+
- step: &turn-on-dev
188+
name: Turn On Dev environment
189+
image: alpine/git:latest
190+
script:
191+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
192+
- export BRANCH_NAME=$(echo "$BITBUCKET_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's|/|--|g')
193+
- 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)}')
194+
- git clone https://x-token-auth:${DSPACE_VALUES_ACCESS_TOKEN}@${DSPACE_VALUES_REPO}
195+
- cd dspace-values
196+
- '[ -f "dev/${BRANCH_FILE}" ] && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" "dev/${BRANCH_FILE}"'
197+
- git config --global user.email "${BB_USER}"
198+
- git config --global user.name "${BB_EMAIL}"
199+
- git commit -am "Enable dev environment for ${BRANCH_NAME}" || echo "No changes to commit"
200+
- git push
201+
202+
- step: &turn-on-staging
203+
name: Turn On Staging environment
204+
image: alpine/git:latest
205+
script:
206+
- export HASH_COMMIT=${BITBUCKET_COMMIT:0:8}
207+
- export BRANCH_NAME=$(echo "$BITBUCKET_BRANCH" | tr '[:upper:]' '[:lower:]' | sed 's|/|--|g')
208+
- 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)}')
209+
- git clone https://x-token-auth:${DSPACE_VALUES_ACCESS_TOKEN}@${DSPACE_VALUES_REPO}
210+
- cd dspace-values
211+
- '[ -f "staging/${BRANCH_FILE}" ] && sed -i "s/^\([[:space:]]*replicaCount:\) 0/\1 1/" "staging/${BRANCH_FILE}"'
212+
- git config --global user.email "${BB_USER}"
213+
- git config --global user.name "${BB_EMAIL}"
214+
- git commit -am "Enable staging environment for ${BRANCH_NAME}" || echo "No changes to commit"
215+
- git push
23216

24217
pipelines:
218+
custom:
219+
e2e-on-custom-backend:
220+
- step: *preliminary-operation-backend
221+
- step: *angular-build
222+
- parallel: &parallel-run-tests
223+
- step: *unittest-code-checks
224+
- step: *run-e2e-tests
225+
deploy-on-dev:
226+
- step: *angular-build
227+
- step: *build-and-push
228+
- step: *deploy-on-dev
229+
turn-on-dev:
230+
- step: *turn-on-dev
231+
turn-on-staging:
232+
- step: *turn-on-staging
25233
branches:
26234
'dspace-cris-2024_02_x':
27-
- step: *unittest-code-checks
235+
- step: *preliminary-operation
236+
- step: *angular-build
237+
- parallel: *parallel-run-tests
238+
- step: *build-and-push
239+
- step: *deploy-on-dev
240+
- step: *deploy-on-staging
28241
'prod/**':
29-
- step: *unittest-code-checks
242+
- step: *preliminary-operation
243+
- step: *angular-build
244+
- parallel: *parallel-run-tests
245+
- step: *build-and-push
246+
- step: *deploy-on-dev
247+
- step: *deploy-on-staging
30248
pull-requests:
31249
'**':
32-
- step: *unittest-code-checks
250+
- step: *preliminary-operation
251+
- step: *angular-build
252+
- parallel: *parallel-run-tests

cypress.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,5 @@ export default defineConfig({
6262
]
6363
},
6464
defaultCommandTimeout: 10000,
65+
requestTimeout: 20000,
6566
});

cypress/e2e/community-create.cy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ beforeEach(() => {
44
});
55

66
it('should show loading component while saving', () => {
7+
cy.intercept('**/sites/**canSubmit**').as('canSubmit');
8+
cy.wait('@canSubmit');
9+
710
const title = 'Test Community Title';
811
cy.get('#title').type(title);
912

0 commit comments

Comments
 (0)