chore: containerized static deploy (Docker + Caddy) for self-hosting
Serve the built PWA behind your own domain: multi-stage Dockerfile builds dist/ and serves it with Caddy on :80 (TLS terminated at your Cloudflare edge). Caddyfile sets no-cache on sw.js/index/manifest and immutable on hashed assets; SPA fallback to index.html. docker-compose maps :8087. Verified locally: image builds, container serves 200s with correct cache headers and SPA fallback. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
8f807d50b5
commit
89b89572b5
@@ -0,0 +1,8 @@
|
||||
node_modules
|
||||
dist
|
||||
.git
|
||||
.github
|
||||
ios
|
||||
resources
|
||||
.superpowers
|
||||
*.log
|
||||
@@ -0,0 +1,15 @@
|
||||
:80 {
|
||||
root * /srv
|
||||
encode gzip zstd
|
||||
|
||||
# The service worker and entry HTML must never be cached, so PWA updates land.
|
||||
@nocache path /sw.js / /index.html /manifest.webmanifest
|
||||
header @nocache Cache-Control "no-cache"
|
||||
|
||||
# Hashed build assets and icons are content-addressed → cache forever.
|
||||
@immutable path /assets/* /icons/*
|
||||
header @immutable Cache-Control "public, max-age=31536000, immutable"
|
||||
|
||||
try_files {path} /index.html
|
||||
file_server
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# Build the PWA, then serve the static bundle with Caddy.
|
||||
# TLS is terminated at your edge (Cloudflare tunnel / reverse proxy), so the
|
||||
# container serves plain HTTP on :80.
|
||||
|
||||
# ---- build ----
|
||||
FROM node:20-alpine AS build
|
||||
WORKDIR /app
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# ---- serve ----
|
||||
FROM caddy:2-alpine
|
||||
COPY Caddyfile /etc/caddy/Caddyfile
|
||||
COPY --from=build /app/dist /srv
|
||||
EXPOSE 80
|
||||
@@ -0,0 +1,9 @@
|
||||
services:
|
||||
director:
|
||||
build: .
|
||||
image: the-director:latest
|
||||
container_name: the-director
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
# host:container — point your director.timevans.uk route at host port 8087
|
||||
- "8087:80"
|
||||
Reference in New Issue
Block a user