-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.Dockerfile
49 lines (35 loc) · 1.21 KB
/
server.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
#----------------------------------------------------------#
# First stage: base image for building server app #
#----------------------------------------------------------#
FROM node:16-alpine as base
WORKDIR /build
# Copy package*.json files first in order to make best use of docker layer caching
COPY package*.json ./
COPY server/package*.json ./server/
# npm clean slate install to get reproducible builds and quicker installs
RUN npm ci
# copy rest of the files
COPY *.js ./
COPY server/tsconfig* ./server/
COPY server/*.js ./server/
COPY server/src ./server/src/
#--------------------------------------------------------#
# Second stage: image to build and test node application #
#--------------------------------------------------------#
FROM base as build
# lint project
RUN npm run lint -w server
# build
RUN npm run build -w server
# run unit test
RUN npm run test -w server
#--------------------------------------------#
# Third stage: image to run node application #
#--------------------------------------------#
FROM node:16-alpine
WORKDIR /app
COPY --from=build /build/server/dist/ ./dist/
COPY --from=build /build/server/package*.json ./
RUN npm i --omit=dev
EXPOSE 80
CMD [ "npm", "run", "start:prod" ]