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 <noreply@paperclip.ing>
This commit is contained in:
Mikael Berg
2026-05-20 14:02:15 +00:00
co-authored by Paperclip
parent 8e852fcfd8
commit 3616f8923f
2 changed files with 24 additions and 18 deletions
+11 -3
View File
@@ -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
+13 -15
View File
@@ -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;
}