-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDockerfile
55 lines (50 loc) · 1.43 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
49
50
51
52
53
54
55
ARG NPM_TOKEN
# build & code linting stage
FROM node:12 as builder
ARG NPM_TOKEN
RUN mkdir /app
WORKDIR /app
COPY ./package.json ./package-lock.json ./.babelrc ./
RUN npm ci
COPY ./src ./src
COPY ./contracts/test ./contracts/test
COPY ./README.md .
COPY ./.eslintrc.js ./.prettierrc.js ./.markdownlint.json ./.soliumrc.json ./
RUN npm run validate
RUN npm run build
# truffle build stage
FROM ajmay/truffle:5.0.9 as truffle-builder
ARG NPM_TOKEN
COPY ./contracts ./contracts
COPY ./truffle/package.json ./truffle/package-lock.json
ENV SOLC_VERSION ^0.5.5
RUN npm ci
RUN truffle compile --all
# api testing stage
FROM node:12
ARG NPM_TOKEN
RUN mkdir /app
WORKDIR /app
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/build ./build
COPY --from=truffle-builder /truffle/build/contracts ./build/contracts
COPY ./package.json ./jest.config.js ./jest.setup.js ./
RUN npm run test:ci
# install production dependencies. separate step to protect env secrets
FROM node:12 as prod-dependencies
ARG NPM_TOKEN
RUN mkdir /app
WORKDIR /app
COPY ./package.json ./package-lock.json ./
RUN npm ci --only=prod
# production image stage
FROM node:12
RUN mkdir /app
WORKDIR /app
COPY ./package.json ./package-lock.json ./
COPY --from=prod-dependencies /app/node_modules ./node_modules
COPY --from=builder /app/build ./build
COPY --from=truffle-builder /truffle/build/contracts ./build/contracts
COPY ./config ./config
EXPOSE 80
CMD ["npm", "start"]