About this project

static-server provides a small containerized HTTP file server for static websites and SPA builds. The image is built from scratch with a statically linked Go binary, uses the standard library, requires CGO_ENABLED=0, and runs as UID 65534 without shell, package manager, libc, or runtime writable paths. Core serving capabilities include: - Serving files from SERVE_DIR, with an optional FALLBACK_DIR cascade for baked-in defaults. - SPA mode that returns index.html for extensionless navigation routes while missing asset paths remain 404 responses. - Optional sibling .br and .gz delivery when the client accepts the encoding. - A configurable immutable cache prefix for fingerprinted assets, while HTML and navigation responses use no-cache. - Automatic MIME type registration, including application/wasm for .wasm files. - GET and HEAD only; other methods receive 405 responses. - Disabled directory listings, with directories requiring index.html. - Security headers on responses and an optional Content-Security-Policy setting. The server exposes /healthz for Kubernetes liveness and readiness checks, /version for the build-time version, and /llms.txt as a machine-readable reference. It handles SIGTERM for graceful shutdown and content can be supplied through a read-only bind mount, ConfigMap, emptyDir populated by an initContainer, or another volume. Configuration is environment-variable based, including PORT, SERVE_DIR, FALLBACK_DIR, SPA_FALLBACK, CACHE_IMMUTABLE_PREFIX, CONTENT_SECURITY_POLICY, and PRECOMPRESSED. The repository includes Docker run examples, Kubernetes Deployment manifests, Kustomize ConfigMap generation, partial overlay examples, and initContainer patterns for build output or template rendering. Images are published to Quay.io and Docker Hub with latest and versioned tags. Local builds use Docker, Docker Buildx, Make, and Go 1.24 or newer; multi-platform linux/amd64 and linux/arm64 builds are supported. Build arguments customize OCI labels and the default index.html template. CI runs go vet and race-enabled tests, while tag publishing pushes multi-platform images. The project is released under the BSD Zero Clause license.