16cad3fe36
- Add sharp dependency for image format conversion - Generate WebP (quality 80) and AVIF (quality 70) variants for all raster images - Render <picture> elements with srcset fallbacks (AVIF > WebP > original) - SVG images remain as <img> without picture wrapper - Update Dockerfile to install libvips for sharp, copy from public/ dir - Add nginx cache rules for .webp and .avif files - Add .gitignore for node_modules, public, dist
42 lines
1.0 KiB
Docker
42 lines
1.0 KiB
Docker
# Build stage
|
|
FROM node:22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install build dependencies for sharp (libvips)
|
|
RUN apk add --no-cache python3 make g++ vips-dev
|
|
|
|
# Copy package files and install dependencies
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# Copy source and build
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# Production stage — nginx serving static files
|
|
FROM nginx:alpine
|
|
|
|
# Copy built site
|
|
COPY --from=builder /app/public /usr/share/nginx/html
|
|
|
|
# Copy ads.txt if present at root
|
|
COPY --from=builder /app/public/ads.txt /usr/share/nginx/html/ads.txt
|
|
|
|
# Custom nginx config for SPA/history routing with image format support
|
|
RUN echo 'server { \
|
|
listen 80; \
|
|
server_name localhost; \
|
|
root /usr/share/nginx/html; \
|
|
index index.html; \
|
|
location / { \
|
|
try_files $uri $uri/ /index.html; \
|
|
} \
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|webp|avif)$ { \
|
|
expires 1y; \
|
|
add_header Cache-Control "public, immutable"; \
|
|
} \
|
|
}' > /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|