refactor: remove Nginx and serve application via Node + Vite preview
This commit is contained in:
+8
-43
@@ -1,9 +1,5 @@
|
|||||||
# Multi-stage production Dockerfile for gameno-front (Vue 3 + Vite SPA)
|
# Production Dockerfile for gameno-front (Node + Vite)
|
||||||
|
FROM node:22-alpine
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
# Stage 1: Build the Vite static application
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
FROM node:22-alpine AS build
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@@ -18,44 +14,13 @@ COPY . .
|
|||||||
ARG VITE_API_BASE_URL
|
ARG VITE_API_BASE_URL
|
||||||
ENV VITE_API_BASE_URL=${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
|
RUN npm run build
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
EXPOSE 5174
|
||||||
# Stage 2: Production web server serving static files via Nginx
|
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
FROM nginx:1.27-alpine AS production
|
|
||||||
|
|
||||||
# Inline Nginx configuration for SPA routing, gzip, caching, and healthcheck
|
# Healthcheck targeting port 5174
|
||||||
RUN printf 'server {\n\
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
||||||
listen 80;\n\
|
CMD wget --no-verbose --tries=1 --spider http://localhost:5174/ || exit 1
|
||||||
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
|
|
||||||
|
|
||||||
# Copy compiled static assets from build stage
|
CMD ["npx", "vite", "preview", "--host", "0.0.0.0", "--port", "5174"]
|
||||||
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;"]
|
|
||||||
|
|||||||
Reference in New Issue
Block a user