From 08270362af488bcff6ff373c253225781e2f040c Mon Sep 17 00:00:00 2001 From: Mohammed Mohsin <59914433+mdmohsin7@users.noreply.github.com> Date: Sun, 15 Dec 2024 16:49:10 +0530 Subject: [PATCH] multistage --- personas-open-source/Dockerfile | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/personas-open-source/Dockerfile b/personas-open-source/Dockerfile index 5a17fcbcb..24feef0ff 100644 --- a/personas-open-source/Dockerfile +++ b/personas-open-source/Dockerfile @@ -1,7 +1,7 @@ -# Use Node.js LTS version -FROM node:18-alpine +FROM node:18-alpine AS base -# Set working directory +# Install dependencies only when needed +FROM base AS deps WORKDIR /app # Copy package files @@ -10,9 +10,23 @@ COPY package*.json ./ # Install dependencies and types RUN npm install --legacy-peer-deps && \ npm install --save-dev @types/mixpanel-browser --legacy-peer-deps -# && \ - # npm install --save-dev @types/mixpanel-browser --legacy-peer-deps +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +#COPY frontend/. . +COPY frontend . +ENV API_URL=https://backend-hhibjajaja-uc.a.run.app +RUN npm run build + +RUN echo "base files" +RUN ls -la + + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app COPY --from=deps /app/node_modules ./node_modules # Copy all files @@ -55,3 +69,5 @@ EXPOSE 3000 # Start the application CMD ["npm", "start"] + +