Minize node app docker image by following blog https://medium.com/trendyol-tech/how-we-reduce-node-docker-image-size-in-3-steps-ff2762b51d5a which reduced the image size from 700 mb to 330 mb

This commit is contained in:
2021-01-26 09:48:01 +11:00
parent 4f973993d6
commit 29f645b2b9
3 changed files with 17 additions and 10 deletions
+1
View File
@@ -1,2 +1,3 @@
node_modules
dist
.git
+15 -5
View File
@@ -1,14 +1,24 @@
FROM node:alpine as build
FROM node as build
WORKDIR /app
# copy the app, note .dockerignore
COPY . /app
RUN apk update \
&& apk add --no-cache git python alpine-sdk\
&& npm ci \
RUN npm ci \
&& npm run build \
&& npm run generate
&& npm run generate \
&& npm prune --production \
&& curl -sf https://gobinaries.com/tj/node-prune | sh \
&& node-prune
FROM node:alpine
WORKDIR /app
# copy from build image
COPY --from=build /app ./
EXPOSE 3000
CMD [ "npm", "start" ]
+1 -5
View File
@@ -1,9 +1,5 @@
export default {
/*
** Nuxt rendering mode
** See https://nuxtjs.org/api/configuration-mode
*/
mode: "universal",
ssr: true,
/*
** Nuxt target
** See https://nuxtjs.org/api/configuration-target