// Compose-stack suite (plan step 3.1b): the release images built from this repo, started // with the real docker-compose.yml + proxy config (the one install.sh writes, CS-5), on // their own project name and ports. Checks what only a real stack can show: // - the terminal image is served on :8082 (SPA fallback, its assets, /api and the // WebSocket through both nginx hops) // - the plain-HTTP ports (:8082, and :8081 as a control) refuse a non-LAN address and // answer a LAN one (two docker networks: 100.64.50.0/24 is not in the allow list) // - the proxy still starts when the stack has no terminal container (older compose file) // node stack.mjs (builds the images: a few minutes the first time, cached after) import { execFileSync, spawnSync } from 'node:child_process' import { reporter } from './lib/env.mjs' import { composeStack, waitHttp } from './lib/proc.mjs' const PROJECT = 'xenia-e2e-stack' const T = 19082 const WAN = 'xenia-e2e-wan' const r = reporter('stack: terminal on :8082 (compose)') const stack = composeStack({ project: PROJECT, version: 'e2es', siteId: 'test-site-1', http: 19080, https: 19443, manager: 19081, terminal: T }) const docker = (...a) => execFileSync('docker', a, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }) /** HTTP status of url fetched from a throwaway container on `network` (busybox wget). */ function statusFrom(network, url) { // busybox wget prints the response headers (-S) on stderr, also for a 200 const res = spawnSync('docker', ['run', '--rm', '--network', network, 'nginx:alpine', 'wget', '-S', '-O', '/dev/null', '-T', '5', url], { encoding: 'utf8' }) return Number(`${res.stdout}${res.stderr}`.match(/HTTP\/1\.\d (\d{3})/)?.[1] || 0) } /** The first frame the backend sends a socket opened through :8082 without credentials. */ function firstFrame(url) { return new Promise(resolve => { const ws = new WebSocket(url) const done = v => { clearTimeout(t); try { ws.close() } catch { /* closed */ } resolve(v) } const t = setTimeout(() => done(null), 15_000) ws.onopen = () => ws.send(JSON.stringify({ cursor: 0 })) ws.onmessage = e => done(JSON.parse(e.data)) ws.onerror = () => done(null) }) } try { try { docker('network', 'rm', WAN) } catch { /* not there */ } await stack.up() const home = await fetch(`http://127.0.0.1:${T}/`) const html = await home.text() r.check('terminal: :8082 serves the terminal app', home.status === 200 && html.includes('