-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
36 lines (30 loc) · 898 Bytes
/
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
# -- Base Node ---
FROM node:12-alpine AS base
WORKDIR /usr/src/app
COPY package*.json ./
# -- Build Base ---
FROM base AS build-base
COPY ["./jest.config.js","./tsconfig.json", "./.eslintrc", "./.eslintignore", "./"]
# -- Dependencies Node ---
FROM build-base AS dependencies
RUN npm set progress=false && npm config set depth 0
RUN npm install --only=production
RUN cp -R node_modules prod_node_modules
RUN npm install
# ---- Test ----
FROM dependencies AS test
COPY ./src ./src
RUN npm run lint
RUN npm run test
# ---- Compile ----
FROM build-base AS compile
COPY ./src ./src
COPY --from=dependencies /usr/src/app/node_modules ./node_modules
RUN npm run build
# ---- Release ----
FROM base AS release
COPY --from=dependencies /usr/src/app/prod_node_modules ./node_modules
COPY --from=compile /usr/src/app/dist ./dist
# Expose port and define CMD
ENV NODE_ENV production
CMD npm run start