fix(nginx): no-cache no index.html + immutable nos assets — evita versão congelada no browser
continuous-integration/webhook Falha no deploy de scoreodonto.com (VPS 4)
continuous-integration/webhook Falha no deploy de scoreodonto.com (VPS 4)
This commit is contained in:
+4
-7
@@ -1,17 +1,14 @@
|
||||
# Stage 1: Build Vite React App
|
||||
# Stage 1: Build
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY update-version.js .
|
||||
COPY frontend/package*.json frontend/
|
||||
WORKDIR /app/frontend
|
||||
COPY frontend/package*.json .
|
||||
RUN npm install
|
||||
COPY frontend/ .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Serve static files with high-performance Nginx on port 3013
|
||||
# Stage 2: Serve
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
|
||||
# Simple internal Nginx routing for single-page React router stability
|
||||
RUN echo 'server { listen 3013; location / { root /usr/share/nginx/html; index index.html; try_files $uri $uri/ /index.html; } }' > /etc/nginx/conf.d/default.conf
|
||||
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 3013
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
server {
|
||||
listen 3013;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# Assets com hash (Vite): cache imutável por 1 ano
|
||||
location /assets/ {
|
||||
add_header Cache-Control "public, max-age=31536000, immutable";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
# index.html: nunca cachear — o browser sempre busca a versão mais recente
|
||||
location / {
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
add_header Pragma "no-cache";
|
||||
add_header Expires "0";
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user