1 | FROM node:12.16.2 as base
|
2 | LABEL maintainer="hedgecock.d@gmail.com"
|
3 |
|
4 | WORKDIR /usr/src
|
5 |
|
6 | # Include serve globally for testing production builds
|
7 | RUN npm install -g serve
|
8 |
|
9 | # --- TEST ---
|
10 |
|
11 | FROM base as test
|
12 |
|
13 | # Install dependencies
|
14 | COPY ./package*.json ./
|
15 | RUN CI=true CYPRESS_INSTALL_BINARY=0 npm install --no-optional --loglevel error
|
16 |
|
17 | # Copy remaining source files
|
18 | COPY . .
|
19 |
|
20 | # Validate unit tests
|
21 | RUN npm run test:lint
|
22 | RUN npm run test:unit
|
23 |
|
24 | # --- APP CLONE ---
|
25 |
|
26 | FROM base as app
|
27 |
|
28 | RUN git clone https://github.com/crystal-ball/react-application-prototype.git
|
29 | WORKDIR /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
|
33 | COPY --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 .
|
38 | COPY ./package.json ./source.package.json
|
39 | COPY ./scripts/prepare-container-install.js ./scripts/prepare-container-install.js
|
40 | RUN node scripts/prepare-container-install.js
|
41 |
|
42 | RUN CI=true CYPRESS_INSTALL_BINARY=0 npm install --no-optional --loglevel error
|
43 |
|
44 | # Copy project source to installed version package
|
45 | COPY ./src /usr/src/react-application-prototype/node_modules/@crystal-ball/webpack-base/src
|
46 | COPY ./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`
|
50 | RUN echo "{ \"public\": \"public\" }" >> ./serve.json
|
51 |
|
52 | # Run Build
|
53 | RUN npm run build
|
54 |
|
55 | # Serve the app in the container on :5000
|
56 | CMD ["serve"]
|