Prevents Cloudflare from caching zip file responses. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
60 lines
1.4 KiB
Docker
60 lines
1.4 KiB
Docker
# Build stage
|
|
FROM node:20-slim AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm ci
|
|
|
|
# Copy source files
|
|
COPY . .
|
|
|
|
# Set build-time environment variable for API URL
|
|
ENV VITE_API_URL=https://dispos.crawlsy.com
|
|
|
|
# Build the app
|
|
RUN npm run build
|
|
|
|
# Production stage
|
|
FROM nginx:alpine
|
|
|
|
# Copy built assets from builder stage
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Copy custom nginx config for SPA routing
|
|
RUN echo '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; \
|
|
\
|
|
# Cache static assets \
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { \
|
|
expires 1y; \
|
|
add_header Cache-Control "public, immutable"; \
|
|
} \
|
|
\
|
|
# WordPress plugin downloads - no cache for zip files \
|
|
location /wordpress/ { \
|
|
add_header Cache-Control "no-cache, must-revalidate"; \
|
|
types { application/zip zip; } \
|
|
default_type application/octet-stream; \
|
|
} \
|
|
\
|
|
# SPA fallback - serve index.html for all routes \
|
|
location / { \
|
|
try_files $uri $uri/ /index.html; \
|
|
} \
|
|
}' > /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|