From 3616f8923f4e06afe02bf100cd2d7b30cfdc1791 Mon Sep 17 00:00:00 2001 From: Mikael Berg Date: Wed, 20 May 2026 14:02:15 +0000 Subject: [PATCH] chore: apply Mikael's Dockerfile and nginx.conf improvements - Dockerfile: add NEXT_PUBLIC_LOOPS_FORM_ID build arg for Loops waitlist integration - nginx.conf: add RSS feed MIME type, Permissions-Policy header, remove _next/static special case (redundant with static asset catch-all) Co-Authored-By: Paperclip --- Dockerfile | 14 +++++++++++--- nginx.conf | 28 +++++++++++++--------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2187900..7b8b55b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,23 @@ -# Stage 1: build Next.js static export +# Stage 1: build FROM node:20-alpine AS builder WORKDIR /app + COPY package*.json ./ -RUN npm ci --prefer-offline +RUN npm ci --prefer-offline --cache /tmp/npm-cache + COPY . . + +# Accept build-time env vars (baked into static output) +ARG NEXT_PUBLIC_LOOPS_FORM_ID +ENV NEXT_PUBLIC_LOOPS_FORM_ID=$NEXT_PUBLIC_LOOPS_FORM_ID + RUN npm run build -# Stage 2: serve with nginx (non-root, port 8080) +# Stage 2: serve FROM nginx:1.27-alpine COPY --from=builder /app/out /usr/share/nginx/html COPY nginx.conf /etc/nginx/conf.d/default.conf EXPOSE 8080 + HEALTHCHECK --interval=30s --timeout=3s --start-period=5s \ CMD wget -qO- http://localhost:8080/ || exit 1 diff --git a/nginx.conf b/nginx.conf index ad802d0..cbd2114 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,34 +1,32 @@ server { listen 8080; - server_name _; root /usr/share/nginx/html; index index.html; - # Next.js static export — trailing slash pages live at /page/index.html + # Static routes — trailing slash handled by next export + trailingSlash: true location / { - try_files $uri $uri/ $uri.html $uri/index.html =404; + try_files $uri $uri/ $uri.html =404; } - # Long-lived cache for immutable assets (Next.js _next/static) - location /_next/static/ { + # Long-lived cache for hashed assets + location ~* \.(js|css|png|jpg|webp|avif|svg|ico|woff2|woff|ttf)$ { expires 1y; add_header Cache-Control "public, immutable"; } - # Long-lived cache for other static assets - location ~* \.(js|css|png|jpg|jpeg|webp|avif|svg|ico|woff2|woff|ttf|otf)$ { - expires 1y; - add_header Cache-Control "public, immutable"; + # RSS feed — correct MIME type + location = /blog/rss.xml { + add_header Content-Type "application/rss+xml; charset=utf-8"; } # Security headers - add_header X-Frame-Options "SAMEORIGIN" always; - add_header X-Content-Type-Options "nosniff" always; - add_header Referrer-Policy "strict-origin-when-cross-origin" always; - - # Plausible analytics — no cross-origin block needed (script loaded from stats.using.cash) + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Content-Type-Options "nosniff"; + add_header Referrer-Policy "strict-origin-when-cross-origin"; + add_header Permissions-Policy "camera=(), microphone=(), geolocation=()"; + # Compression gzip on; - gzip_types text/plain text/css application/json application/javascript text/xml application/xml image/svg+xml; + gzip_types text/plain text/css application/javascript application/json image/svg+xml application/xml; gzip_min_length 1024; }