Final Dockerfile + nginx + index.html

This commit is contained in:
Vivek 2026-06-08 12:07:33 +00:00
parent 064af0661e
commit 473a214b1b
2 changed files with 12 additions and 18 deletions

View file

@ -8,39 +8,37 @@ RUN apk add --no-cache git
WORKDIR /app
# Copy package files first (for caching)
# Copy package files
COPY package.json package-lock.json* ./
# Install dependencies (use npm install instead of npm ci for compatibility)
# Install dependencies
RUN npm install
# Copy remaining files
# Copy source files
COPY . .
# Build the production bundle - swipe env vars at build time
# Build the production bundle (Vite substitutes 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 build output files exist
# DEBUG: Verify build output
RUN echo "=== BUILD OUTPUT ===" && \
ls -la /app/dist && \
cat /app/dist/index.html | head -n 10 || echo "ERROR: index.html missing"
cat /app/dist/index.html | head -n 5 || echo "ERROR: index.html missing"
# ---------------------------------------------------------
# Production stage nginx serving static files
# Production stage nginx static server
# ---------------------------------------------------------
FROM nginx:alpine
# Copy custom nginx config
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Copy built assets into nginx's web root
# Copy the compiled React app
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80

View file

@ -1,23 +1,19 @@
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri /index.html;
try_files $uri $uri/ /index.html;
}
location = /health {
add_header Content-Type text/plain;
return 200 "OK\n";
access_log off;
return 200 "OK";
add_header Content-Type text/plain;
}
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml;
access_log off;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
}