From 93970f361b831f17d48ff2a345fc78488ac71fba Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 23 Nov 2026 00:51:32 +0100 Subject: Phase 7: hardening and shipping (M7) E2E (Playwright, e2e/): - table fixture: one real compiled server per test (temp saves dir, free port, workers: 1); a Tab helper drives the real UI (menus, rows, initiative, draw, seats) over one WS per fresh browser context - full round: onboarding, secret initiative masked to ?? per connection, draw revealing on every screen, turns, next round, round-2 secrecy - seats: claim/re-claim on owner-leave, reload keeps the session and re-claims, two sessions can't own one character - resilience: a dropped tab resyncs on reconnect (no drift); a SIGKILL'd server restarts with state + seats surviving (incl. the owner's secret initiative and the enabled draw); a throttled tab converges on the same state as the fast tabs; a double-tapped draw runs once, error sent to the sender only - figure edit: set a character level + rename from the status menu Cross-check vs the reference (feature parity): - status menu: level pills (setCharacterLevel) + a name field (changeName), mirroring SetCharacterLevelMenu - ability-card removal: draw-pile-only "send to bottom" (reorderAbilityList -> index 0) + "shuffle undrawn cards" (shuffleDrawnAbilityCard), mirroring RemoveCardMenu - Add Character: already-added classes disabled (Objective/Escort may be added repeatedly), matching _characterAlreadyAdded - every remaining registry command verified reachable from the UI Session persistence (found by the restart test): - the client never learned its session id before the first welcome, so a reconnect minted a new id and orphaned the restored seat; fixed with establishSessionCookie() (a GET /session before the WS upgrade, plus a vite /session proxy) so the x-haven-session cookie survives restarts - the initiative input now prefills from re-synced state (CharacterRow effect, guarded against clobbering a live edit) so a reload/reconnect doesn't blank an entry Performance + deployment: - immutable asset caching (Cache-Control: 1yr, immutable) for the game data / images / in-game translations; no-cache for the SPA index.html so rebuilt apps reach open tabs - server tool/perf_measure.dart: the performance probe (state payload size at full-table scale, WS fan-out bytes per action, traffic per connection) - Dockerfile (server + built web); docs/DEPLOYMENT.md (Docker, persistence, reverse proxy, measured performance, smoke-test list) - README quickstart + production/Docker/testing sections Server: - --saves-dir and --data-dir CLI options (Docker / multi-game hosts), threaded through the stores and data loading Misc: - app.css: height 100% on .row so the turn-done tap zone resolves to a clickable height; fake-socket.ts readyState constants corrected to the real WebSocket values (0 CONNECTING, 1 OPEN) - scripts/ci.sh: the Playwright E2E gate (runs when PLAYWRIGHT is set) - PLAN.md: Phase 7 boxes checked, M7 progress-log entry Verification: svelte-check 0 errors; web 196/196 tests; vite build OK; dart analyze 0 errors / 0 warnings; dart test 604/604; Playwright 9/9; scripts/ci.sh green end-to-end. --- Dockerfile | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Dockerfile (limited to 'Dockerfile') diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cd43d7c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,53 @@ +# X-Haven (web) — server + built web app (PLAN.md Phase 7). +# +# Three stages: +# 1. `web` — build the Svelte app (npm ci + vite build → dist/) +# 2. `server` — compile the Dart server to a standalone native binary +# 3. runtime — debian-slim + the binary + the game assets + the web build +# +# Build and run: +# docker build -t xhaven . +# docker run --rm -p 4567:4567 -v xhaven-saves:/app/saves xhaven +# +# See docs/DEPLOYMENT.md for configuration, persistence, and scaling notes. + +# --- 1. web build --------------------------------------------------------- +FROM node:22 AS web +WORKDIR /web +COPY web/package.json web/package-lock.json ./ +RUN npm ci --no-audit --no-fund +COPY web/ . +RUN npm run build + +# --- 2. server build ------------------------------------------------------- +FROM dart:3.11 AS server +WORKDIR /server +COPY server/pubspec.yaml server/pubspec.lock ./ +RUN dart pub get +COPY server/ . +# Standalone native binary — the runtime image needs no Dart SDK. +RUN dart compile exe bin/main.dart -o /out/xhaven-server + +# --- 3. runtime ------------------------------------------------------------- +FROM debian:bookworm-slim +# ca-certificates only: no SDK, no package manager residue. +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +WORKDIR /app +COPY --from=server /out/xhaven-server /app/xhaven-server +COPY server/assets/ /app/assets/ +COPY --from=web /web/dist /app/web/dist + +# The game state (game.json, seats.json, settings.json, saves/) lives in a +# volume so a redeploy keeps the game. +ENV PORT=4567 +EXPOSE 4567 +VOLUME ["/app/saves"] + +# bash is in the base image; /dev/tcp gives a dependency-free health probe. +HEALTHCHECK --interval=30s --timeout=5s --start-period=15s \ + CMD bash -c 'exec 3<>/dev/tcp/127.0.0.1/${PORT:-4567}' || exit 1 + +CMD ["/app/xhaven-server", "--port=4567", "--static-dir=/app/web/dist", "--saves-dir=/app/saves", "--data-dir=/app/assets/data/"] -- cgit v1.3.1