Skip to content

Commit 84da90c

Browse files
authored
feat(db): ship CA bundle with @trycompai/db, clean up debug routes (#2767)
After the verified-TLS PR (#2761) merged, two follow-ups didn't make it in: 1. Add 'certs' to packages/db/package.json files array so the RDS CA bundle ships with the published @trycompai/db package. Downstream consumers (e.g. comp-private/apps/enterprise-api) can then reference the cert at node_modules/@trycompai/db/certs/rds-global-bundle.pem instead of committing their own copy. 2. Delete the debug-tls routes (apps/app/src/app/api/_debug-tls and apps/app/src/app/api/debug-tls) that were merged in via auto-PRs #2762 and #2763 but never cleaned up. They were temporary verification endpoints, since used to confirm the Vercel cert path. 3. Update the deploy checklist with verified-staging notes and the downstream consumer pattern.
1 parent e999c72 commit 84da90c

4 files changed

Lines changed: 27 additions & 82 deletions

File tree

apps/app/src/app/api/_debug-tls/route.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

apps/app/src/app/api/debug-tls/route.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/plans/secure-rds-tls-deploy-checklist.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,37 @@ After merging the secure-rds-tls PR, the following env vars must be set per envi
44

55
## Vercel (apps/app and apps/portal)
66

7-
Set on each Vercel project, all environments (preview + production):
7+
Set on each Vercel project, all environments (Production + Preview + Development):
88

99
```
1010
NODE_EXTRA_CA_CERTS=/var/task/packages/db/certs/rds-global-bundle.pem
1111
```
1212

13-
The cert is bundled into the deployed function via `outputFileTracingIncludes` in `next.config.ts`.
14-
At Vercel runtime the function CWD is conventionally `/var/task`, so the path above is the first
15-
candidate. If a preview deploy crashes with "Refusing to connect" or "ENOENT", the runtime cwd
16-
isn't `/var/task` — try instead:
17-
18-
```
19-
NODE_EXTRA_CA_CERTS=/vercel/path0/packages/db/certs/rds-global-bundle.pem
20-
```
21-
22-
Both paths can be tested with a preview deploy. The wrong one produces an ENOENT error at boot;
23-
the right one succeeds silently.
13+
Verified on staging (apps/app): `process.cwd()` is `/var/task/apps/app`, the cert is traced
14+
into the deploy at `/var/task/packages/db/certs/rds-global-bundle.pem` (165408 bytes), and
15+
`/api/health` succeeds end-to-end. The cert is bundled via `outputFileTracingIncludes` in
16+
each app's `next.config.ts`.
17+
18+
## Downstream consumers (comp-private/apps/enterprise-api, etc.)
19+
20+
The CA bundle now ships with the published `@trycompai/db` package (added to the `files` array
21+
in this PR). After the next `@trycompai/db` publish, downstream consumers can ship the cert with
22+
their own Vercel/Docker/Trigger.dev builds without committing a copy.
23+
24+
For Vercel-deployed apps that install `@trycompai/db` from npm:
25+
26+
1. Bump the dependency to the version that includes `certs/`.
27+
2. Add `outputFileTracingIncludes` to `next.config.{ts,mjs}`:
28+
```ts
29+
outputFileTracingIncludes: {
30+
'/**/*': ['./node_modules/@trycompai/db/certs/rds-global-bundle.pem'],
31+
},
32+
```
33+
3. Set the Vercel env var:
34+
```
35+
NODE_EXTRA_CA_CERTS=/var/task/node_modules/@trycompai/db/certs/rds-global-bundle.pem
36+
```
37+
4. Apply the same strict-TLS Prisma client logic (or import a shared helper from `@trycompai/db`).
2438

2539
## Trigger.dev (api and app projects, staging + prod)
2640

packages/db/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
},
3737
"files": [
3838
"dist",
39+
"certs",
3940
"README.md",
4041
"INTEGRATION_GUIDE.md"
4142
],

0 commit comments

Comments
 (0)