forked from cartsnitch/app
5ad8fb806f
Build stage uses node:20-alpine to install deps and build. Prod stage uses nginx:stable-alpine to serve static assets. Includes nginx config with SPA routing, gzip, health endpoint, and aggressive caching for Vite-hashed assets. Closes #6 Co-Authored-By: Paperclip <noreply@paperclip.ing>
36 lines
927 B
Nginx Configuration File
36 lines
927 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
|
|
gzip_min_length 256;
|
|
|
|
# Health endpoint for K8s probes
|
|
location /health {
|
|
access_log off;
|
|
return 200 'ok';
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
# Cache static assets aggressively (Vite hashes filenames)
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Service worker — must not be cached
|
|
location /sw.js {
|
|
expires off;
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
}
|
|
|
|
# SPA fallback — serve index.html for all routes
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|