Rene Nochebuena fa04364413 chore(spa-server): add Makefile and OCI image labels to Dockerfile
Makefile:
- dry-run target (default) shows registry, branch, SHA, version, all computed
  image tags, and build args — no side effects
- build/push/release targets wire docker build and docker push
- Branch-aware tag strategy:
    main        → <version> + latest
    develop     → <version>-dev-<short-sha>
    release/*   → <version>-qa-<short-sha>
- Version resolved from the highest semver tag at HEAD; falls back to the most
  recent reachable tag via git describe
- BASE_DIGEST resolved at build time from the local Docker daemon; dry-run
  prints a hint when the base image is not yet pulled
- Note: case/esac cannot be used inside $(shell) — Make's parser matches the
  pattern ")" as the function's closing paren before the shell sees it;
  if/elif/else/fi used instead

Dockerfile:
- OCI standard labels added to the final stage via build args (VERSION, GIT_SHA,
  BASE_DIGEST):
    org.opencontainers.image.source    — repo URL
    org.opencontainers.image.version   — semver tag
    org.opencontainers.image.revision  — git commit SHA
    org.opencontainers.image.base.name — alpine:3.21
    org.opencontainers.image.base.digest — digest of base image at build time
- Custom label:
    dev.nochebuena.healthz — /health
2026-06-02 19:07:31 +00:00

einherjar/spa-server

version license go

A shield wall holds because every warrior knows their position. The SPA asks only for the wall — not for every soldier's name.

code.nochebuena.dev/einherjar/spa-server is a container-first HTTP server for single-page applications and progressive web apps. It serves static assets directly and falls back to index.html for any path that does not resolve to a file on disk — the standard SPA routing contract.

The module ships as a ready-to-use Docker base image. Deploying a SPA to a container requires a single COPY instruction. No nginx, no custom configuration, no index.html redirect logic to maintain.


Container usage

FROM code.nochebuena.dev/einherjar/spa-server:v1.0.0
COPY dist/ /srv/www/

That is the complete Dockerfile for a production SPA container.


Environment variables

Variable Default Description
EINHERJAR_SPA_PORT 8080 TCP port the server listens on
EINHERJAR_SPA_STATIC_DIR /srv/www Path to the directory containing index.html and assets
EINHERJAR_LOG_LEVEL INFO Log level: DEBUG, INFO, WARN, ERROR

Health endpoint

GET /health returns 200 OK with a JSON body consistent with all Einherjar health responses:

{"status":"UP","components":{}}

503 Service Unavailable is never returned — if the process is alive, it is healthy. Wire /health directly to your container liveness and readiness probes.


Routing behaviour

Request Result
/app.js — file exists Served directly with correct Content-Type
/assets/logo.png — file exists Served directly
/dashboard — no matching file index.html served (SPA router handles it)
/ — directory index.html served (directory listing is disabled)

Dependency graph

contracts  (zero dependencies)
    ↑
  core
    ↑
spa-server  (contracts, core, stdlib only)

No external dependencies beyond the Go standard library.


Verification

cd spa-server/
go build ./...
go vet ./...
go test ./...
gofmt -l .

A shield wall holds because every warrior knows their position. The SPA asks only for the wall — not for every soldier's name.

Description
SPA and PWA container server with static file serving, index.html fallback routing, and health endpoint
Readme AGPL-3.0 62 KiB
2026-06-02 13:08:33 -06:00
Languages
Go 70%
Makefile 24.3%
Dockerfile 5.7%