Support production deployment on Linux/nginx via SSH tunnel#48
Merged
Conversation
- Bundle @timefraim/shared into the server dist via tsup.config.ts: the shared package's exports point at TypeScript source, so the previous externalized import crashed node dist/index.js. - Locate the repo-root .env by walking up to pnpm-workspace.yaml instead of a fixed parent-hop count that broke once the code was bundled. - Add `start` (server) and `start:server` (root) scripts. - Add docs/deploy-linux-prod.md: production runbook for Linux/nginx served over an SSH tunnel (single loopback origin, API proxied). - Point .env.example at the runbook; update agent briefs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The ESLint project service had no project covering tsup.config.ts, producing a parsing error in editors. Mirror the web package idiom (vite.config.ts in include) and lint it explicitly; rootDir is dropped since tsc is noEmit-only here and tsup controls output layout. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Running the built server (
node dist/index.js) previously crashed: tsup externalized@timefraim/shared, whose packageexportspoints at TypeScript source that Node can't load at runtime. There was also nostartscript, and the bundled code computed the repo root with a fixed../../../../from its own location — correct forsrc/config/env.ts, wrong fordist/index.js, so the root.envwasn't found unless the process happened to run from the repo root.apps/server/tsup.config.ts— bundles@timefraim/sharedintodist/index.js(config file replaces the inline CLI flags). Verified the output has zero runtime references to the workspace package.apps/server/src/config/env.ts— locates the repo root by walking up topnpm-workspace.yamlinstead of a fixed parent-hop count, so.envdiscovery works from bothsrc(tsx dev) and the bundleddist.startin the server package,start:serverat the root.docs/deploy-linux-prod.md— production runbook written for a coding agent: nginx on loopback:6173servesapps/web/distand proxies/api,/health,/mcpto the API on:4000, reached through a single SSH tunnel port. Includes the prod.envtemplate (linked Supabase values, IPv4 session-poolerDATABASE_URL), a systemd unit, SPA-fallback nginx config with unbuffered/mcp, verification steps, and a troubleshooting table.apps/server/tsconfig.json— includestsup.config.ts(mirrors web'svite.config.tsidiom) so the ESLint project service can type it;rootDirdropped sincetscis--noEmithere and tsup controls output layout. Server lint now covers the config file.AGENTS.mdupdated andCLAUDE.md/GEMINI.mdregenerated viapnpm agent-briefs:sync;.env.examplepoints at the runbook.Why
The app worked under
pnpm devon a server but had no viable production path: the dev server was the only way to run it. This makespnpm build && pnpm start:serverwork and documents the full nginx/tunnel topology so the same origin (http://127.0.0.1:6173) keeps Supabase Google OAuth andAPP_ORIGINCORS working withNODE_ENV=production.Reviewer notes
NODE_ENV=productionfrom a non-root cwd:/healthreturns{"ok":true}, the root.envis found, configured origins get CORS headers, and foreign origins are rejected.pnpm checkcomponents (agent-briefs check, lint, typecheck, 144 tests, build).🤖 Generated with Claude Code