From 5e330d8f54f7abfd8c5c6dd994b07aac7977f5de Mon Sep 17 00:00:00 2001 From: Juan Sebastian Montoya Date: Fri, 4 Oct 2024 12:23:29 -0500 Subject: [PATCH] Improve production image size --- dockerfile => Dockerfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) rename dockerfile => Dockerfile (60%) diff --git a/dockerfile b/Dockerfile similarity index 60% rename from dockerfile rename to Dockerfile index 2119924..5f7bfa5 100644 --- a/dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -#Build stage +# Build stage FROM node:18-alpine AS build WORKDIR /app COPY package*.json . @@ -6,11 +6,16 @@ RUN npm ci COPY . . RUN npm run build -#Prod stage -FROM node:18-alpine AS production +# Deps stage +FROM node:18-alpine AS dependencies WORKDIR /app COPY package*.json . RUN npm ci --omit=dev -COPY --from=build /app/dist ./dist +# Prod stage +FROM node:18-alpine AS production +WORKDIR /app +COPY package*.json . +COPY --from=build /app/dist ./dist +COPY --from=dependencies /app/node_modules ./node_modules CMD ["npm", "run", "start"]