Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit ec64ecb

Browse files
committed
refactor(docker): Use multi stage build to lower docker image size
1 parent ac52810 commit ec64ecb

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

generator/template/Dockerfile

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
FROM node:alpine
2-
3-
EXPOSE 8080
4-
1+
# build static files
2+
FROM node:alpine as frontend
53
WORKDIR /usr/src/app
6-
7-
RUN npm install serve -g
8-
9-
COPY package.json package-lock.json ./
10-
11-
RUN npm install
12-
4+
COPY package.json .
5+
RUN npm install --silent
136
COPY . .
14-
157
RUN npm run build
168

9+
# final image
10+
FROM node:alpine
11+
EXPOSE 8080
12+
WORKDIR /usr/src/app
13+
RUN npm install serve -g
14+
COPY --from=frontend /usr/src/app/dist ./dist
1715
USER node
18-
1916
CMD ["serve", "--single", "--port", "8080", "dist"]

0 commit comments

Comments
 (0)