Move server from nginx to vite

This commit is contained in:
Ahmed DCHAR 2025-11-03 00:24:52 +01:00
parent 9e573e0761
commit a3cdcdee25

View File

@ -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-slim
FROM node:20-alpine AS builder
WORKDIR /app WORKDIR /app
# Copy package files # Copy package files
COPY package*.json ./ COPY package*.json ./
# Install dependencies (use npm install because package-lock.json may not exist in the repo) # Install dependencies (including Vite for preview server)
# and ensure terser is available for Vite's production minification. RUN npm install --no-audit --no-fund
RUN npm install --no-audit --no-fund && npm install --no-audit --no-fund --save-dev terser
# Copy source files # Copy source files
COPY . . COPY . .
# Build the application # Build the application for production
RUN npm run build RUN npm run build
# Stage 2: Serve with nginx # Expose port for Vite preview server
FROM nginx:alpine EXPOSE 8081
# Copy custom nginx configuration # Set production environment
COPY nginx.conf /etc/nginx/conf.d/default.conf ENV NODE_ENV=production
# Copy built files from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Expose port 80
EXPOSE 80
# Health check # Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ 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 # Serve the production build with Vite preview server
CMD ["nginx", "-g", "daemon off;"] CMD ["npm", "run", "preview", "--", "--host", "0.0.0.0", "--port", "8081"]