Deploy next.calternal.cloud: image, quadlet, deploy with automatic rollback #45

Closed
kayg wants to merge 0 commits from issue/11-deploy-next into dev
Owner

Part of #11: the dev build runs at https://next.calternal.cloud, with a deploy script and automatic rollback.

Server

  • calternal serve --web DIR (or CALTERNAL_WEB) serves a built web app. Deep links get index.html, and /api and /healthz are never shadowed. Without it, the server shows the placeholder page as before. New test: crates/server/tests/web.rs.

Image (deploy/Containerfile)

  • Bun builds apps/web, Rust builds the calternal binary (release, locked), and a debian-slim runtime runs it as uid 10001 with only libssl3 and CA certificates. It's 145 MB, ready in about 50 ms.
  • Health check: deploy/healthz.sh (bash /dev/tcp, no curl in the image).

next (deploy/next/)

  • calternal-next.container: rootless quadlet as calternal on calternal-staging, published on 10.70.3.158:8080 (Traefik's target), data in /srv/calternal-next/data (keep-id, so the host user owns it), origin https://next.calternal.cloud.
  • deploy.sh: builds HEAD (or takes a tag), streams docker save into podman load over ssh, then runs remote.sh deploy.
  • remote.sh steps:
    1. tag the running build :rollback
    2. stop the old process, which flushes and releases the data lock, and wait until no container holds it
    3. snapshot the data (keep 5)
    4. start the new build, which must answer /healthz within 60 s
    5. otherwise restore the snapshot plus :rollback automatically
  • rollback.sh [--data] does the same by hand. README.md covers both.

Verified

  • curl https://next.calternal.cloud/healthz returns {"status":"ok","version":"0.1.0"}, a deep link returns 200, and the podman health status is healthy.
  • Rollback test: I deployed a deliberately broken build (starts, never answers).
    • It was declared unhealthy after 60 s, and 10 s later the earlier build was live again with data restored from the pre-deploy snapshot.
    • A deploy of an image that isn't loaded aborts before touching anything.
  • fmt, clippy -D warnings and the server + binary tests pass in the CI image.

Also done on staging: removed about 79 GB of old v0 staging images (root disk was 99% full, now 15%).

🤖 Generated with Claude Code

https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T

Part of #11: the dev build runs at https://next.calternal.cloud, with a deploy script and automatic rollback. **Server** - `calternal serve --web DIR` (or `CALTERNAL_WEB`) serves a built web app. Deep links get `index.html`, and `/api` and `/healthz` are never shadowed. Without it, the server shows the placeholder page as before. New test: `crates/server/tests/web.rs`. **Image** (`deploy/Containerfile`) - Bun builds `apps/web`, Rust builds the `calternal` binary (release, locked), and a debian-slim runtime runs it as uid 10001 with only `libssl3` and CA certificates. It's 145 MB, ready in about 50 ms. - Health check: `deploy/healthz.sh` (bash `/dev/tcp`, no curl in the image). **next** (`deploy/next/`) - `calternal-next.container`: rootless quadlet as `calternal` on calternal-staging, published on `10.70.3.158:8080` (Traefik's target), data in `/srv/calternal-next/data` (keep-id, so the host user owns it), origin `https://next.calternal.cloud`. - `deploy.sh`: builds HEAD (or takes a tag), streams `docker save` into `podman load` over ssh, then runs `remote.sh deploy`. - `remote.sh` steps: 1. tag the running build `:rollback` 2. stop the old process, which flushes and releases the data lock, and wait until no container holds it 3. snapshot the data (keep 5) 4. start the new build, which must answer `/healthz` within 60 s 5. otherwise restore the snapshot plus `:rollback` automatically - `rollback.sh [--data]` does the same by hand. `README.md` covers both. **Verified** - `curl https://next.calternal.cloud/healthz` returns `{"status":"ok","version":"0.1.0"}`, a deep link returns 200, and the podman health status is `healthy`. - **Rollback test:** I deployed a deliberately broken build (starts, never answers). - It was declared unhealthy after 60 s, and 10 s later the earlier build was live again with data restored from the pre-deploy snapshot. - A deploy of an image that isn't loaded aborts before touching anything. - fmt, clippy `-D warnings` and the server + binary tests pass in the CI image. **Also done on staging:** removed about 79 GB of old v0 staging images (root disk was 99% full, now 15%). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
- calternal serve --web DIR (CALTERNAL_WEB) serves a built web app;
  deep links get index.html, /api and /healthz are never shadowed
- deploy/Containerfile: bun builds apps/web, rust builds the binary,
  debian-slim runtime as uid 10001 with a bash /dev/tcp health check
- deploy/next: quadlet unit, deploy.sh (build, podman load over ssh),
  remote.sh (stop, snapshot, start, health check, automatic rollback
  with data restore), rollback.sh

Part of #11

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Deploy next: ship the unit over ssh (no sftp on staging), README
All checks were successful
CI / rust (pull_request) Successful in 1m0s
CI / web (pull_request) Successful in 1m35s
e4f728d488
Part of #11

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Yyy8fQGxPLkLa8v8NXz7T
Author
Owner

Recreated to rerun CI: the only failure was the web job's cpu x6 layout-shift test hitting the 30 s timeout at load average 30+ on the CI host (no web code changed here).

Recreated to rerun CI: the only failure was the web job's cpu x6 layout-shift test hitting the 30 s timeout at load average 30+ on the CI host (no web code changed here).
kayg closed this pull request 2026-10-13 18:53:31 +00:00
All checks were successful
CI / rust (pull_request) Successful in 1m0s
CI / web (pull_request) Successful in 1m35s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!45
No description provided.