From 8ce5060e88adfcbe3fe737e4f7fe1d4da3531287 Mon Sep 17 00:00:00 2001 From: Vivek Date: Mon, 8 Jun 2026 10:43:30 +0000 Subject: [PATCH] Fix: update Dockerfile with build verification and npm install --- Dockerfile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 61d1478..02e5a06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,37 +1,41 @@ # --------------------------------------------------------- -# --------------------------------------------------------- # Build stage # --------------------------------------------------------- FROM node:18-alpine AS builder -# Install git (only needed for npm postinstall scripts) +# Install git (needed by some npm packages) RUN apk add --no-cache git WORKDIR /app -# Copy package files -COPY package.json ./ +# Copy only package files first (leverages caching) +COPY package.json package-lock.json* ./ + +# Install dependencies (npm ci uses lockfile, but we don't have it) +# Using npm install instead for broader compatibility RUN npm install -# Copy the rest of the source tree +# Copy source files COPY . . -# Build the production bundle (Vite outputs to `dist/`) +# Build the production bundle (outputs to /app/dist) ENV NODE_ENV=production RUN npm run build -# DEBUG: Confirm build output exists before proceeding -RUN echo "=== BUILD OUTPUT CHECK ===" && \ +# DEBUG: Verify the build output exists before proceeding +RUN echo "=== BUILD OUTPUT ===" && \ ls -la /app/dist && \ - cat /app/dist/index.html 2>/dev/null | head -n 5 || echo "ERROR: INDEX NOT FOUND - build may have failed silently" + cat /app/dist/index.html | head -n 10 || echo "ERROR: index.html missing" # --------------------------------------------------------- -# Production stage – tiny static server (nginx) +# Production stage – nginx serving the static files # --------------------------------------------------------- FROM nginx:alpine +# Custom nginx config COPY nginx.conf /etc/nginx/conf.d/default.conf +# Copy the compiled React app into nginx's web root COPY --from=builder /app/dist /usr/share/nginx/html EXPOSE 80