-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathDockerfile
48 lines (36 loc) · 1.55 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
ARG NODE_VERSION=14
ARG JEST_VERSIONS=19
FROM node:20.10.0 AS build
# Pass arguments as environment variables so they persists when we switch Node version
ENV JEST_VERSIONS=$JEST_VERSIONS
# Build the Jest HTML Reporter package
WORKDIR /app
COPY . .
RUN yarn install
RUN yarn bundle
# Switch to a different Node version
FROM node:${NODE_VERSION}-slim AS final
# Re-declare environment variables as we have switched node
ARG JEST_VERSIONS
ENV JEST_VERSIONS=$JEST_VERSIONS
WORKDIR /app
# Copy over the Jest HTML Reporter package we built in the previous step
COPY --from=build /app/dist /app/jest-html-reporter/dist
COPY --from=build /app/style /app/jest-html-reporter/style
COPY --from=build /app/package.json /app/jest-html-reporter/package.json
COPY --from=build /app/yarn.lock /app/jest-html-reporter/yarn.lock
# Install jest-html-reporter dependencies using yarn
WORKDIR /app/jest-html-reporter
ENV NODE_ENV=production
RUN npm install --ignore-engines
# Copy and run the test-project directory into the container and run the tests with the Jest HTML Reporter
WORKDIR /app
COPY /e2e/test-project /app
# As a test results processor
RUN echo "{\"testEnvironment\": \"node\", \"testResultsProcessor\": \"<rootDir>/jest-html-reporter\"}" > /app/jest.config.json
RUN echo "{\"pageTitle\": \"A Testresult Processor Title\", \"outputPath\": \"<rootDir>/testResultsProcessor.html\"}" > /app/jesthtmlreporter.config.json
RUN npm install
# Run the bash script containing the tests
COPY /e2e/run_tests.sh /app/run_tests.sh
RUN chmod +x /app/run_tests.sh
CMD ["/bin/sh", "/app/run_tests.sh"]