UNPKG

1.63 kBPlain TextView Raw
1FROM node:12.16.3 as base
2LABEL maintainer="hedgecock.d@gmail.com"
3
4WORKDIR /usr/src
5
6# Include serve globally for testing production builds
7RUN npm install -g serve
8
9# --- TEST ---
10
11FROM base as test
12
13# Install dependencies
14COPY ./package*.json ./
15RUN CI=true CYPRESS_INSTALL_BINARY=0 npm install --no-optional --loglevel error
16
17# Copy remaining source files
18COPY . .
19
20# Validate unit tests
21RUN npm run test:lint
22RUN npm run test:unit
23
24# --- APP CLONE ---
25
26FROM base as app
27
28RUN git clone https://github.com/crystal-ball/react-application-prototype.git
29WORKDIR /usr/src/react-application-prototype
30
31# Copy test coverage reports for webpack-base so that we can later copy them
32# to CI/CD workspace
33COPY --from=test /usr/src/coverage ./coverage
34
35# Copy source and template packages and run merge script to install the same deps
36# as listed in current package (vs published package deps)
37# COPY ./test-app/package.json .
38COPY ./package.json ./source.package.json
39COPY ./scripts/prepare-container-install.js ./scripts/prepare-container-install.js
40RUN node scripts/prepare-container-install.js
41
42RUN CI=true CYPRESS_INSTALL_BINARY=0 npm install --no-optional --loglevel error
43
44# Copy project source to installed version package
45COPY ./src /usr/src/react-application-prototype/node_modules/@crystal-ball/webpack-base/src
46COPY ./package.json /usr/src/react-application-prototype/node_modules/@crystal-ball/webpack-base/package.json
47
48
49# Copy serve config for prod build testing with `serve`
50RUN echo "{ \"public\": \"public\" }" >> ./serve.json
51
52# Run Build
53RUN npm run build
54
55# Serve the app in the container on :5000
56CMD ["serve"]