From 014017f12763796c9837df9a207910de020aac9c Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Fri, 3 Jul 2026 09:40:34 +0330 Subject: [PATCH] up --- Dockerfile | 62 +++++++++++++++++++++++++++--------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/Dockerfile b/Dockerfile index 518ae86..ebc98d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,33 @@ # -------- Build Stage -------- - FROM node:20-alpine AS builder +FROM node:20-alpine AS builder - WORKDIR /app - - # Copy only dependency files first (better cache) - COPY package*.json ./ - - # Use clean install for reproducible builds - RUN npm ci - - # Copy source after deps (maximizes cache usage) - COPY . . - - # Build with production mode - RUN npm run build - - - # -------- Production Stage -------- - FROM nginx:stable-alpine AS production - - # Copy built assets - COPY --from=builder /app/dist /usr/share/nginx/html - - # Copy nginx config (optional, safer naming) - COPY nginx.conf /etc/nginx/conf.d/default.conf - - # Remove default nginx config if needed (optional safety) - RUN rm -f /etc/nginx/conf.d/default.conf.default || true - - EXPOSE 80 - - CMD ["nginx", "-g", "daemon off;"] \ No newline at end of file +WORKDIR /app + +# Copy only dependency files first (better cache) +COPY package*.json ./ + +# Install devDependencies too (vite, etc.) even when NODE_ENV=production +RUN npm ci --include=dev + +# Copy source after deps (maximizes cache usage) +COPY . . + +# Build with production mode +RUN npm run build + + +# -------- Production Stage -------- +FROM nginx:stable-alpine AS production + +# Copy built assets +COPY --from=builder /app/dist /usr/share/nginx/html + +# Copy nginx config (optional, safer naming) +COPY nginx.conf /etc/nginx/conf.d/default.conf + +# Remove default nginx config if needed (optional safety) +RUN rm -f /etc/nginx/conf.d/default.conf.default || true + +EXPOSE 80 + +CMD ["nginx", "-g", "daemon off;"]