Fix Vite build: use npm install, quiet mode, and proper env var passing
This commit is contained in:
parent
a740b7c361
commit
6936c2b595
2 changed files with 15 additions and 16 deletions
23
Dockerfile
23
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
Loading…
Reference in a new issue