diff --git a/Dockerfile b/Dockerfile index 1448e34..79f99ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,31 @@ -# Multi-stage build for EzSepa Landing Page +# Node-only Dockerfile for EzSepa Landing Page +# Uses Vite's preview server to serve the production build -# Stage 1: Build the application -FROM node:20-alpine AS builder +FROM node:20-slim WORKDIR /app # Copy package files COPY package*.json ./ -# Install dependencies (use npm install because package-lock.json may not exist in the repo) -# and ensure terser is available for Vite's production minification. -RUN npm install --no-audit --no-fund && npm install --no-audit --no-fund --save-dev terser +# Install dependencies (including Vite for preview server) +RUN npm install --no-audit --no-fund # Copy source files COPY . . -# Build the application +# Build the application for production RUN npm run build -# Stage 2: Serve with nginx -FROM nginx:alpine +# Expose port for Vite preview server +EXPOSE 8081 -# Copy custom nginx configuration -COPY nginx.conf /etc/nginx/conf.d/default.conf - -# Copy built files from builder stage -COPY --from=builder /app/dist /usr/share/nginx/html - -# Expose port 80 -EXPOSE 80 +# Set production environment +ENV NODE_ENV=production # Health check HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ - CMD wget --quiet --tries=1 --spider https://ezsepa.com/ || exit 1 + CMD node -e "require('http').get('http://localhost:8081', (r) => process.exit(r.statusCode === 200 ? 0 : 1))" -# Start nginx -CMD ["nginx", "-g", "daemon off;"] +# Serve the production build with Vite preview server +CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8081"]