-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
34 lines (25 loc) · 989 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
# Build image
FROM node:18-alpine AS BUILD_IMAGE
## install curl to fetch node-prune
RUN apk update && apk add curl bash && rm -rf /var/cache/apk/*
## install node-prune (https://github.com/tj/node-prune)
RUN curl -sf https://gobinaries.com/tj/node-prune | bash -s -- -b /usr/local/bin
WORKDIR /usr/app
ADD ./ ./
RUN npm install
RUN npm run build
# ## Cleanup and size optimization
RUN npm prune --production --workspaces
RUN npm prune --production
RUN /usr/local/bin/node-prune ./server/node_modules
RUN /usr/local/bin/node-prune ./node_modules
# Runtime image
FROM node:18-alpine
WORKDIR /usr/app
## Copy runtime build files
COPY --from=BUILD_IMAGE /usr/app/server/dist /usr/app/server/dist
COPY --from=BUILD_IMAGE /usr/app/server/node_modules /usr/app/server/node_modules
COPY --from=BUILD_IMAGE /usr/app/web/dist /usr/app/web/dist
COPY --from=BUILD_IMAGE /usr/app/node_modules /usr/app/node_modules
EXPOSE 3000
CMD [ "node", "./server/dist/server/src/main.js", "--port=3000" ]