# Node-only Dockerfile for EzSepa Landing Page
# Uses Vite's preview server to serve the production build

FROM node:20-slim

WORKDIR /app

# Copy package files
COPY package*.json ./

# Install dependencies (including Vite for preview server)
RUN npm install --no-audit --no-fund && npm install --no-audit --no-fund --save-dev terser

# Copy source files
COPY . .

# Build the application for production
RUN npm run build

# Expose port for Vite preview server
EXPOSE 8081

# Set production environment
ENV NODE_ENV=production

# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node -e "require('http').get('http://localhost:8081', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"

# Serve the production build with Vite preview server (--open false disables browser launch)
CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8081", "--open", "false"]
