use multi-stage build to reduce size (#6938)

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
Su Yang
2021-08-26 01:19:18 +08:00
committed by GitHub
parent 92772de68e
commit 22995e4e35

View File

@@ -1,4 +1,4 @@
FROM node:14-alpine
FROM node:14-alpine AS Builder
RUN mkdir -p /usr/src/app
RUN mkdir /usr/src/app/private
@@ -17,9 +17,14 @@ RUN npm run build
RUN npm prune --production
RUN npm cache clean --force
# Use multi-stage build to reduce size
FROM node:14-alpine
# Run the server using production configs.
ENV NODE_ENV production
WORKDIR /usr/src/app
COPY --from=Builder /usr/src/app /usr/src/app
CMD node server
EXPOSE 80