From 356aae6e24342053c14415f1e5924a31e23805ad Mon Sep 17 00:00:00 2001 From: Kavehhn174 Date: Thu, 13 Aug 2026 11:34:49 +0330 Subject: [PATCH] refactor: remove Nginx and serve application via Node + Vite preview --- Dockerfile | 51 ++++++++------------------------------------------- 1 file changed, 8 insertions(+), 43 deletions(-) diff --git a/Dockerfile b/Dockerfile index 368dcb3..2d65b53 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,5 @@ -# Multi-stage production Dockerfile for gameno-front (Vue 3 + Vite SPA) - -# ------------------------------------------------------------------------------ -# Stage 1: Build the Vite static application -# ------------------------------------------------------------------------------ -FROM node:22-alpine AS build +# Production Dockerfile for gameno-front (Node + Vite) +FROM node:22-alpine WORKDIR /app @@ -18,44 +14,13 @@ COPY . . ARG VITE_API_BASE_URL ENV VITE_API_BASE_URL=${VITE_API_BASE_URL} -# Build static assets to /app/dist +# Build static application RUN npm run build -# ------------------------------------------------------------------------------ -# Stage 2: Production web server serving static files via Nginx -# ------------------------------------------------------------------------------ -FROM nginx:1.27-alpine AS production +EXPOSE 5174 -# Inline Nginx configuration for SPA routing, gzip, caching, and healthcheck -RUN printf 'server {\n\ - listen 80;\n\ - server_name localhost;\n\ - root /usr/share/nginx/html;\n\ - index index.html;\n\ - gzip on;\n\ - gzip_types text/plain text/css text/javascript application/javascript application/json image/svg+xml;\n\ - location ~ ^/(healthz|health)$ {\n\ - access_log off;\n\ - default_type text/plain;\n\ - return 200 "OK";\n\ - }\n\ - location / {\n\ - try_files $uri $uri/ /index.html;\n\ - }\n\ - location ~* \\.(?:css|js|jpg|jpeg|gif|png|ico|svg|woff|woff2|ttf)$ {\n\ - expires 1y;\n\ - access_log off;\n\ - add_header Cache-Control "public, immutable";\n\ - }\n\ -}\n' > /etc/nginx/conf.d/default.conf +# Healthcheck targeting port 5174 +HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:5174/ || exit 1 -# Copy compiled static assets from build stage -COPY --from=build /app/dist /usr/share/nginx/html - -EXPOSE 80 - -# Health check endpoint for Docker & Coolify targeting /healthz -HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:80/healthz || exit 1 - -CMD ["nginx", "-g", "daemon off;"] +CMD ["npx", "vite", "preview", "--host", "0.0.0.0", "--port", "5174"]