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
|
FROM node:20-alpine AS builder
|
||||||
WORKDIR /app
|
|
||||||
COPY update-version.js .
|
|
||||||
COPY frontend/package*.json frontend/
|
|
||||||
WORKDIR /app/frontend
|
WORKDIR /app/frontend
|
||||||
|
COPY frontend/package*.json .
|
||||||
RUN npm install
|
RUN npm install
|
||||||
COPY frontend/ .
|
COPY frontend/ .
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Serve static files with high-performance Nginx on port 3013
|
# Stage 2: Serve
|
||||||
FROM nginx:alpine
|
FROM nginx:alpine
|
||||||
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
|
COPY --from=builder /app/frontend/dist /usr/share/nginx/html
|
||||||
# Simple internal Nginx routing for single-page React router stability
|
COPY frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
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
|
|
||||||
EXPOSE 3013
|
EXPOSE 3013
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -36,7 +36,7 @@ server {
|
|||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Proxy para o Frontend (Next.js SSR)
|
# Proxy para o Frontend (Vite React SPA)
|
||||||
location / {
|
location / {
|
||||||
set $frontend_upstream http://scoreodonto-frontend:3013;
|
set $frontend_upstream http://scoreodonto-frontend:3013;
|
||||||
proxy_pass $frontend_upstream;
|
proxy_pass $frontend_upstream;
|
||||||
|
|||||||
Reference in New Issue
Block a user