-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
46 lines (32 loc) · 1.03 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
# Build
FROM node:16-alpine as builder
# can be needed to install dependencies required by node-gyp
# RUN apk add --no-cache python3 make g++
RUN mkdir -p /usr/src/app/
WORKDIR /usr/src/app/
COPY package.json yarn.lock ./
# disable husky
CMD npm set-script prepare ""
# install all deps required for building
RUN HUSKY_SKIP_INSTALL=true yarn install --frozen-lockfile
COPY . .
RUN yarn build
# Final image
FROM node:16-alpine AS release
USER node
WORKDIR /home/node
# copy
COPY --from=builder /usr/src/app/package.json /home/node/
COPY --from=builder /usr/src/app/yarn.lock /home/node/
COPY --from=builder /usr/src/app/.yarnclean /home/node/
COPY --from=builder /usr/src/app/dist/ /home/node/dist/
# install only production modules
# disable husky
CMD npm set-script prepare ""
# install all deps required for building
RUN HUSKY_SKIP_INSTALL=true yarn install --frozen-lockfile --production
# run autoclean to remove any non required files (node_modules)
RUN yarn autoclean --force
# expose port
EXPOSE 3000
CMD ["node", "dist/src/server.js"]