Fix: update Dockerfile with build verification and npm install

This commit is contained in:
Vivek 2026-06-08 10:43:30 +00:00
parent fb8ccbb237
commit 8ce5060e88

View file

@ -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