-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
35 lines (25 loc) · 875 Bytes
/
Dockerfile
File metadata and controls
35 lines (25 loc) · 875 Bytes
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
#
# This was taken from https://wadehuang36.github.io/2019/10/27/building-docker-image-of-nodejs-with-typescript.html
#
# dockerfile
# the first image use node image as the builder because it has git program
FROM node:12 as builder
LABEL builder=true
WORKDIR /app
COPY ["./package.json", "./package-lock.json", "/app/"]
RUN npm ci
COPY "./" "/app/"
## compile typescript
RUN npm run build
## remove packages of devDependencies
RUN npm prune --production
# ===============
# the second image use node:slim image as the runtime
FROM node:14-slim as runtime
WORKDIR /app
ENV NODE_ENV=production
## Copy the necessary files form builder
COPY --from=builder "/app/out/" "/app/out/"
COPY --from=builder "/app/node_modules/" "/app/node_modules/"
COPY --from=builder "/app/package.json" "/app/package.json"
CMD ["npm", "run", "start:prod"]