Skip to content

Self-host: rebuild the static site automatically on publish (follow-up to #143) #150

Closed

Description

@Madraka

Context

#143 / PR #148 ship the self-host Docker image with site serving option (a): cloudhal build writes static HTML to /data/dist and Caddy serves it from the volume. The image exposes this as the site-build command (docker compose exec cloudhal site-build), run by hand or from cron after a publish. Nothing rebuilds the site automatically when an editor or an agent publishes, so a self-hosted site can serve stale pages until someone runs the command.

Expected

A publish on a self-hosted installation refreshes the served site without an operator step:

  • A publish hook on the Node server (cloudhal studio): when a snapshot is published (the publish path in @cloudhal/core-ts / the API's publish route and RFC-0008's scheduled releases), schedule one cloudhal build run in a child process, debounced so a burst of publishes builds once, serialised so two builds never overlap, with the result (duration, snapshot id, failure) written to the audit log and visible in Studio.
  • The purge step that the Cloudflare site Worker has (onPublished + the release purger) is the natural seam; self-host should hang the build on the same event, so the two runtimes stay symmetrical.
  • Failure handling: a failed build keeps the previous dist (build into a temporary directory, swap atomically), reports in Studio and retries on the next publish.
  • A CLOUDHAL_SITE_BUILD=off escape hatch for installations that build elsewhere (CI, another host), and documentation in docs/guides/self-host.md replacing the manual site-build paragraph.

Not in scope

Live rendering of the site from the store on Node (an Astro Node adapter for starters/blog) is a separate RFC; this issue only closes the gap in option (a).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions