Files
LithosAnanke/demo/DEPLOY.md
T
Claude 6ebe706351 demo: each session's transcript, kept 7 days in a write-only drop box (#192)
Ruled 2026-11-21, "Write-only drop box": console.py writes each session's transcript, mode 0600,
into /var/lib/starshipos-demo-transcripts (the owner's, group starshipos-demo, mode 1730: a session
adds a file but cannot list or read the directory). transcripts-tidy.sh, run as root every 5 minutes
by starshipos-demo-transcripts.timer, hands each file to the owner and deletes those over 7 days.
starshipos-demo.service gets the directory writable and DEMO_TRANSCRIPTS; DEPLOY.md step 4 has the
server steps and the check.

"Nothing you do is kept" was no longer true. Ruled 2026-11-24, "Machine not kept; log 7 days": the
session's banner, the Try it page and the old wiki page say nothing is kept on the machine and a
transcript is kept for up to 7 days, then deleted, and the page says so before the console.

demo/test_transcripts.py failed first (logs/20261121-demo-transcripts/before.txt) and passes its
10 checks (after.txt).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
2026-11-24 09:19:03 +00:00

6.0 KiB

Deploying "Try it" on the server

The public demo: each visitor gets a StarshipOS machine of their own in the browser, resumed at Zuse's prompt, gone when they leave. Two at a time on today's server (384 MiB each); a third visitor is told every machine is busy and to try back in a few minutes. Issues #115, #116, #117.

Run as root on the server, after PR #148 is merged (it carries the 384 MiB guests and the busy message), while CI is idle (each step that boots QEMU boots one, in the foreground).

1. The checkout and what the build needs (~15 min)

apt-get install -y ttyd qemu-system-x86 ovmf python3 git
git clone https://gitea.starshipos-f18.org/rajames/LithosAnanke.git /opt/starshipos-demo
cd /opt/starshipos-demo
git checkout master                  # after #148: alpha.3's kernel, and the demo's limits
make ARCH=amd64 init INIT_DOCS=0 INIT_PROOFS=0     # amd64 only: no docs, no Isabelle

Master after #148 is the v4.0.0-alpha.3 kernel unchanged, plus #148's scripts.

2. The demo's own Zuse (~3 min, two QEMU boots)

demo/mint-zuse.sh /var/lib/starshipos-demo-zuse
ls -la /var/lib/starshipos-demo-zuse/zusestick.img     # the stick every session attaches

Never anyone's real Zuse: minted for the demo (#111), its writes discarded in every session.

3. The image and the saved machine (~2 min, one QEMU boot)

demo/build-iso.sh /tmp/StarshipOS.iso
DEMO_PROMPT='[zuse@Hera]' demo/make-snapshot.sh /tmp/StarshipOS.iso /var/lib/starshipos-demo \
    /var/lib/starshipos-demo-zuse/zusestick.img
ls -la /var/lib/starshipos-demo/            # StarshipOS.iso identity.img vars.fd state

The saved machine belongs to this image, this QEMU and 384 MiB: re-run step 3 after any of them changes. Sessions already running keep theirs.

4. The service (~5 min)

Ubuntu's ttyd package starts its own ttyd.service, which runs login on port 7681 -- our port. Left running, it takes the port, and Apache hands visitors the server's own login prompt (found 2026-11-08, after step 5). Disable it first:

systemctl disable --now ttyd                 # the package's service: a login prompt on 7681
useradd --system --home /var/lib/starshipos-demo --shell /usr/sbin/nologin starshipos-demo
chown -R starshipos-demo: /var/lib/starshipos-demo
cp demo/starshipos-demo.service /etc/systemd/system/
systemctl daemon-reload && systemctl enable --now starshipos-demo
systemctl status starshipos-demo --no-pager | head -5
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:7681/     # 200: ttyd answers
ss -ltnp | grep 7681                          # the ttyd of starshipos-demo, nothing else

The service expects the checkout's demo/ at /opt/starshipos-demo/demo (step 1 put it there).

The transcripts (#192, ruled 2026-11-21: "Write-only drop box"). Each session writes what the visitor typed and what the machine answered to /var/lib/starshipos-demo-transcripts, one file per session, mode 0600 (console.py). The directory is yours, group starshipos-demo, mode 1730: a session can add a file, but cannot list the directory or read anything in it. A root timer hands each file to you and deletes every one older than 7 days (transcripts-tidy.sh). The Try it page says so. Before (re)starting the service, with OWNER your own login:

OWNER=<your login>
install -d -o "$OWNER" -g starshipos-demo -m 1730 /var/lib/starshipos-demo-transcripts
sed "s/^Environment=OWNER=CHANGE-ME$/Environment=OWNER=$OWNER/" \
    demo/starshipos-demo-transcripts.service > /etc/systemd/system/starshipos-demo-transcripts.service
cp demo/starshipos-demo-transcripts.timer /etc/systemd/system/
systemctl daemon-reload && systemctl enable --now starshipos-demo-transcripts.timer
systemctl restart starshipos-demo            # its unit now writes the transcripts directory
systemctl list-timers starshipos-demo-transcripts --no-pager

Then the check: open a session, type a line, close it; within 5 minutes its file is in /var/lib/starshipos-demo-transcripts, owned by you, mode -rw-------, and sudo -u starshipos-demo ls /var/lib/starshipos-demo-transcripts is refused. A file older than 7 days (touch -d '8 days ago' FILE.log) is gone at the next run (systemctl start starshipos-demo-transcripts runs it at once). Apache must not serve the directory: nothing in apache-demo.conf maps it, and nothing should.

5. TLS and Apache for try.starshipos-f18.com (~10 min)

DNS: try.starshipos-f18.com must point at this server (an A record) before certbot.

a2enmod proxy proxy_http proxy_wstunnel headers ssl rewrite
certbot certonly --apache -d try.starshipos-f18.com
cp demo/apache-demo.conf /etc/apache2/sites-available/starshipos-demo.conf
a2ensite starshipos-demo && apachectl configtest && systemctl reload apache2
curl -sI https://try.starshipos-f18.com/ | head -3                   # 200, its own certificate

apache-demo.conf lets only the .com frame the terminal (frame-ancestors).

6. The check (done 2026-11-08)

From outside: a session ready 1.5 s after the page opens; 3 4 + . answers 7 ok, : SQUARE DUP * ; 7 SQUARE . answers 49 ok; a third visitor at once is told every machine is busy. The certificate is try.starshipos-f18.com's own (Let's Encrypt), and only the .com may frame it.

7. Tell Claude

Then I check from outside: a session reaches [zuse@Hera] ok>, 3 4 + . answers 7 ok, a third visitor gets the busy message, and the .com's Try it page shows the console. Then the "Try it" link goes into the .com's navigation (#117).

If something goes wrong

  • journalctl -u starshipos-demo -n 50 -- ttyd and the sessions
  • A session that ends at once: the saved machine does not match (re-run step 3)
  • Memory: free -h -- a session's QEMU holds ~150 MB of its 384 MiB guest; two at most (DEMO_MAX_GUESTS in the service)
  • CPU: an idle guest keeps a host core busy (the kernel's idle loop polls -- its own issue), so the service caps all sessions together at one core (CPUQuota=100%, Nice=19). After changing the service file: systemctl daemon-reload && systemctl restart starshipos-demo