From 36a3b5a0b2fdfeaf9d1046dd41014f164e2203fc Mon Sep 17 00:00:00 2001 From: Travis Gilbert <1travisgilbert@gmail.com> Date: Sat, 15 Aug 2026 22:21:56 -0400 Subject: [PATCH] Add Fly.io deploy for the console at apps.theoremweb.com. The production Next image needs a repo-root Dockerfile, hoist-aware install, and two typecheck fixes so `next build` can complete on Fly. --- .dockerignore | 24 +++++++++++++ apps/console/Dockerfile | 25 +++++++++++++ apps/console/src/views/RecordTableView.tsx | 14 ++++---- apps/console/src/views/model/ModelView.tsx | 2 +- fly.console.toml | 42 ++++++++++++++++++++++ 5 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 .dockerignore create mode 100644 apps/console/Dockerfile create mode 100644 fly.console.toml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..33a1a724 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,24 @@ +.git +**/.git +**/.env +**/.env.* +!**/.env.example +.pnpm-store +crates +**/node_modules +**/.next +**/dist +**/test-results +**/.turbo +apps/desktop +apps/mobile +apps/browser-native +apps/chat +apps/commonplace-collab +apps/theorem-vscode +apps/commonplace-api +.theorem +.full-stack-feature +.playwright-mcp +plans +docs diff --git a/apps/console/Dockerfile b/apps/console/Dockerfile new file mode 100644 index 00000000..8affa0be --- /dev/null +++ b/apps/console/Dockerfile @@ -0,0 +1,25 @@ +# CommonPlace console for Fly. Build context is the CommonPlace repo root. +FROM node:22-bookworm + +WORKDIR /app +ENV NEXT_TELEMETRY_DISABLED=1 +ENV PORT=8080 + +RUN corepack enable + +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./ +COPY apps/console ./apps/console +COPY packages ./packages +COPY .commonplace-canonical .commonplace-canonical + +# NEXT_PUBLIC_* is inlined at `next build`. Runtime Fly secrets do not reach this step. +ARG NEXT_PUBLIC_CONSOLE_CHAT_URL=/api/chat/stream +ARG NEXT_PUBLIC_THEOREM_GATEWAY_URL= +ENV NEXT_PUBLIC_CONSOLE_CHAT_URL=$NEXT_PUBLIC_CONSOLE_CHAT_URL +ENV NEXT_PUBLIC_THEOREM_GATEWAY_URL=$NEXT_PUBLIC_THEOREM_GATEWAY_URL + +RUN pnpm install --no-frozen-lockfile --filter @commonplace/console... \ + && pnpm --filter @commonplace/console run build:railway + +EXPOSE 8080 +CMD ["node", "apps/console/scripts/start-railway.mjs"] diff --git a/apps/console/src/views/RecordTableView.tsx b/apps/console/src/views/RecordTableView.tsx index a5f8442e..e393537d 100644 --- a/apps/console/src/views/RecordTableView.tsx +++ b/apps/console/src/views/RecordTableView.tsx @@ -262,13 +262,15 @@ export function RecordTableView({ set: initialSet, host, instance }: ViewRenderP setCellFocus((current) => (current ? { ...current, mode: 'soft' } : current)); return; } - const note = receipt.value?.note ?? ''; + const receiptValue = receipt.value as + | { note?: string; code?: string; refusal?: { code?: string } } + | undefined; + const note = receiptValue?.note ?? ''; const code = - typeof receipt.value?.code === 'string' - ? receipt.value.code - : typeof (receipt.value as { refusal?: { code?: string } } | undefined)?.refusal - ?.code === 'string' - ? (receipt.value as { refusal: { code: string } }).refusal.code + typeof receiptValue?.code === 'string' + ? receiptValue.code + : typeof receiptValue?.refusal?.code === 'string' + ? receiptValue.refusal.code : null; if (code || /reject|enforcement|refused|validated|put_item_validated/i.test(note)) { setSchemaRowProperty(rowId, fieldKey, previous); diff --git a/apps/console/src/views/model/ModelView.tsx b/apps/console/src/views/model/ModelView.tsx index 8ce3dd1e..2b1270a2 100644 --- a/apps/console/src/views/model/ModelView.tsx +++ b/apps/console/src/views/model/ModelView.tsx @@ -901,7 +901,7 @@ export function ModelView({ set, host }: ViewRenderProps) { if (ghost) void applyPin(ghost.observedKey, 'type'); }, declareDisabled: proposalBusy || observed.types.length === 0, - onSpawnObject: (position) => { + onSpawnObject: (position: { x: number; y: number }) => { void spawnObject(position); }, onCompareVersion: (id: string) => { diff --git a/fly.console.toml b/fly.console.toml new file mode 100644 index 00000000..6a3e2979 --- /dev/null +++ b/fly.console.toml @@ -0,0 +1,42 @@ +# CommonPlace product console. Public hostname is apps.theoremweb.com +# (apex theoremweb.com stays on Vercel / Theseus). +# +# Deploy from the CommonPlace repo root: +# fly deploy --config fly.console.toml --app travis-commonplace-console +app = "travis-commonplace-console" +primary_region = "iad" +kill_signal = "SIGTERM" +kill_timeout = "30s" + +[build] + dockerfile = "apps/console/Dockerfile" + + [build.args] + NEXT_PUBLIC_CONSOLE_CHAT_URL = "/api/chat/stream" + +[env] + PORT = "8080" + HOSTNAME = "0.0.0.0" + AUTH_TRUST_HOST = "true" + AUTH_URL = "https://apps.theoremweb.com" + +[http_service] + internal_port = 8080 + force_https = true + auto_stop_machines = "off" + auto_start_machines = true + min_machines_running = 1 + processes = ["app"] + + [[http_service.checks]] + grace_period = "1m" + interval = "15s" + method = "GET" + path = "/api/healthz" + protocol = "http" + timeout = "10s" + +[[vm]] + size = "shared-cpu-2x" + memory = "2gb" + processes = ["app"]