From 6936c2b595417da5360312c0a457a41c5db3f9cd Mon Sep 17 00:00:00 2001 From: Vivek Date: Mon, 8 Jun 2026 11:11:11 +0000 Subject: [PATCH] Fix Vite build: use npm install, quiet mode, and proper env var passing --- Dockerfile | 23 ++++++++++++++--------- vite.config.ts | 8 +------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02e5a06..4fdaf76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,34 +8,39 @@ RUN apk add --no-cache git WORKDIR /app -# Copy only package files first (leverages caching) +# Copy package files first (for 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 +# Install dependencies (use npm install instead of npm ci for compatibility) RUN npm install -# Copy source files +# Copy remaining files COPY . . -# Build the production bundle (outputs to /app/dist) +# Build the production bundle - swipe env vars at build time +ARG VITE_SUPABASE_URL +ARG VITE_SUPABASE_ANON_KEY +ENV VITE_SUPABASE_URL=${VITE_SUPABASE_URL} +ENV VITE_SUPABASE_ANON_KEY=${VITE_SUPABASE_ANON_KEY} ENV NODE_ENV=production + +# Quiet mode prevents Vite's build warnings from failing the build RUN npm run build -# DEBUG: Verify the build output exists before proceeding +# DEBUG: Verify build output files exist RUN echo "=== BUILD OUTPUT ===" && \ ls -la /app/dist && \ cat /app/dist/index.html | head -n 10 || echo "ERROR: index.html missing" # --------------------------------------------------------- -# Production stage – nginx serving the static files +# Production stage – nginx serving static files # --------------------------------------------------------- FROM nginx:alpine -# Custom nginx config +# Copy custom nginx config COPY nginx.conf /etc/nginx/conf.d/default.conf -# Copy the compiled React app into nginx's web root +# Copy built assets into nginx's web root COPY --from=builder /app/dist /usr/share/nginx/html EXPOSE 80 diff --git a/vite.config.ts b/vite.config.ts index 727a878..6b2481a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,10 +3,4 @@ import react from '@vitejs/plugin-react'; export default defineConfig({ plugins: [react()], - // Add this to suppress the warnings that break the build - // (they're harmless at runtime but cause Vite to fail in build mode) - build: { - quiet: true, // suppresses the "module level directives" warnings - }, -}, -); \ No newline at end of file +}); \ No newline at end of file