FROM node:20-slim AS builder WORKDIR /app RUN npm install -g pnpm COPY package.json pnpm-lock.yaml* ./ RUN pnpm install COPY . . ARG VITE_API_BASE_URL ARG VITE_GOOGLE_CLIENT_ID ENV VITE_API_BASE_URL=$VITE_API_BASE_URL ENV VITE_GOOGLE_CLIENT_ID=$VITE_GOOGLE_CLIENT_ID RUN pnpm run build-no-error RUN chmod -R a+r /app/dist && find /app/dist -type d -exec chmod a+rx {} \; FROM nginx:alpine COPY --from=builder /app/dist /usr/share/nginx/html RUN printf 'server {\n\ listen 80;\n\ server_name _;\n\ root /usr/share/nginx/html;\n\ index index.html;\n\ \n\ # index.html : jamais mis en cache, toujours revalidé\n\ location = /index.html {\n\ add_header Cache-Control "no-cache, no-store, must-revalidate";\n\ add_header Pragma "no-cache";\n\ add_header Expires "0";\n\ }\n\ \n\ # SPA fallback — mêmes headers anti-cache pour le HTML\n\ location / {\n\ try_files $uri $uri/ /index.html;\n\ add_header Cache-Control "no-cache, no-store, must-revalidate";\n\ add_header Pragma "no-cache";\n\ }\n\ \n\ # Assets hashés par Vite (ex: index-abc123.js) — cache agressif OK\n\ location /assets/ {\n\ expires 1y;\n\ add_header Cache-Control "public, immutable";\n\ }\n\ \n\ # Autres fichiers statiques (favicon, images, fonts)\n\ location ~* \\.(png|jpg|jpeg|gif|ico|svg|woff2|webp)$ {\n\ expires 7d;\n\ add_header Cache-Control "public";\n\ }\n\ }\n' > /etc/nginx/conf.d/default.conf EXPOSE 80