meldestelle/config/docker/caddy/web-app/Caddyfile
Stefan Mogeritsch 11c597f147 feat: add runtime configuration for Caddy-based SPA containerization
Introduced `config.json` runtime configuration fetch mechanism to support the "Build Once, Deploy Everywhere" pattern. Replaced NGINX with Caddy for SPA deployment, enabling SPA routing, security headers, and static asset management. Updated Gradle and Kotlin/JS build configurations to align with the new runtime environment. Enhanced Dockerfile and health checks for optimized CI/CD workflows and improved SPA delivery.
2026-02-02 16:19:20 +01:00

42 lines
1.0 KiB
Caddyfile

:4000 {
# Root directory for static files
root * /usr/share/caddy
# Enable Gzip/Zstd compression
encode gzip zstd
# Serve static files
file_server
# Templates for runtime configuration (config.json)
templates {
mime application/json
}
# SPA Routing: Fallback to index.html for non-existent files
try_files {path} /index.html
# Cache Control for static assets (immutable)
@static {
file
path *.js *.css *.png *.jpg *.svg *.wasm
}
header @static Cache-Control "public, max-age=31536000, immutable"
# Security Headers (Future Proofing for Wasm)
header {
# Cross-Origin Isolation for SharedArrayBuffer (required for some Wasm features)
Cross-Origin-Opener-Policy "same-origin"
Cross-Origin-Embedder-Policy "require-corp"
# Standard Security Headers
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
}
# Health Check
handle /health {
respond "healthy" 200
}
}