Deploy hu13 with Docker

deploy · wiki index

Deploy hu13 with Docker

Build the image

From the repo root (build context is sources only — see .dockerignore):

docker build -t hu13 .

Multi-stage: rust:1.98-bookworm compiles with cargo build --locked --release (only Cargo.toml, Cargo.lock, src/, static/ are copied, so edits elsewhere don't bust the cache); debian:bookworm-slim runtime adds ca-certificates, a nonroot user hu13 (uid 10000), the binary, and entrypoint.sh. No toolchain, no sources, no .git in the final image.

Run it

docker run --rm -p 39313:39313 \
  -v "$PWD:/data/repo:ro" \
  -v hu13-inbox:/data/inbox \
  -e HU13_BRANCH=main \
  -e HU13_PUBLIC_ORIGIN=http://localhost:39313 \
  -e HU13_CLONE_URL=https://example.com/mirror.git \
  hu13

Then open http://localhost:39313/.

What happens inside (entrypoint.sh):

  1. hu13 build /data/repo -o /srv/www (+ --branch / --clone-url / --public-origin only when HU13_BRANCH / HU13_CLONE_URL / HU13_PUBLIC_ORIGIN are set). Any failure — bad branch, unreadable repo — aborts LOUD before serving starts (set -eu; serve never runs on a stale/empty site). The build emits repo.git (a dumb-HTTP bare repo: git clone <origin>/repo.git, no smart server needed), repo.bundle and repo.tar.gz.
  2. exec hu13 serve --www /srv/www --inbox-dir /data/inbox --listen 0.0.0.0:39313 (+ --max-title, --max-body, --max-bytes, --rate-per-hour, --quota only when the matching HU13_* env var is set; otherwise the serve defaults apply). exec keeps serve on PID 1.

Volumes / env reference

Mount / varDefaultNotes
/data/repo (ro)—repo checkout to render (required)
/data/inbox—inbox storage; MUST sit outside --www (serve refuses otherwise)
HU13_BRANCHmain, else masterbranch to build; wrong name fails the container
HU13_PUBLIC_ORIGINunsetabsolute base URL; enables git clone <origin>/repo.git + absolute bundle/tarball links
HU13_CLONE_URLgit origin remotefallback/mirror label shown as "mirror source"
HU13_LISTEN0.0.0.0:39313serve address
HU13_MAX_TITLE300inbox title cap (chars)
HU13_MAX_BODY20000inbox body/prompt cap (chars)
HU13_MAX_BYTES32768whole-POST cap (bytes)
HU13_RATE_PER_HOUR2per-IP POSTs/hour
HU13_QUOTA500global inbox file quota

Notes