Skip to content

Commit b7b7944

Browse files
fix: install ca-certificates before wget, clean apt after download (#2434)
Co-authored-by: Mariano Fuentes <marfuen98@gmail.com>
1 parent 772ac48 commit b7b7944

8 files changed

Lines changed: 34 additions & 12 deletions

File tree

.github/workflows/trigger-tasks-deploy-main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ jobs:
3636
- name: Copy schema to app and generate client
3737
working-directory: ./apps/app
3838
run: |
39-
mkdir -p prisma
40-
cp ../../packages/db/dist/schema.prisma prisma/schema.prisma
41-
bunx prisma generate
39+
mkdir -p prisma/schema
40+
find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \;
41+
bunx prisma generate --schema=prisma/schema
4242
- name: 🚀 Deploy Trigger.dev
4343
working-directory: ./apps/app
4444
timeout-minutes: 20

.github/workflows/trigger-tasks-deploy-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
- name: Copy schema to app and generate client
4343
working-directory: ./apps/app
4444
run: |
45-
mkdir -p prisma
46-
cp ../../packages/db/dist/schema.prisma prisma/schema.prisma
47-
bunx prisma generate
45+
mkdir -p prisma/schema
46+
find ../../packages/db/prisma/schema -name '*.prisma' ! -name 'schema.prisma' -exec cp {} prisma/schema/ \;
47+
bunx prisma generate --schema=prisma/schema
4848
4949
- name: 🚀 Deploy Trigger.dev
5050
working-directory: ./apps/app

apps/api/prisma/client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ const globalForPrisma = global as unknown as { prisma: PrismaClient };
66
function createPrismaClient(): PrismaClient {
77
const url = process.env.DATABASE_URL!;
88
const isLocalhost = /localhost|127\.0\.0\.1|::1/.test(url);
9-
const adapter = new PrismaPg({ connectionString: url, ssl: isLocalhost ? undefined : true });
9+
// Use verified SSL when NODE_EXTRA_CA_CERTS is set (Docker with RDS CA bundle),
10+
// otherwise fall back to unverified SSL (Trigger.dev, Vercel, other environments).
11+
const hasCABundle = !!process.env.NODE_EXTRA_CA_CERTS;
12+
const ssl = isLocalhost ? undefined : hasCABundle ? true : { rejectUnauthorized: false };
13+
const adapter = new PrismaPg({ connectionString: url, ssl });
1014
return new PrismaClient({ adapter });
1115
}
1216

apps/app/prisma/client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ const globalForPrisma = global as unknown as { prisma: PrismaClient };
66
function createPrismaClient(): PrismaClient {
77
const url = process.env.DATABASE_URL!;
88
const isLocalhost = /localhost|127\.0\.0\.1|::1/.test(url);
9-
const adapter = new PrismaPg({ connectionString: url, ssl: isLocalhost ? undefined : true });
9+
// Use verified SSL when NODE_EXTRA_CA_CERTS is set (Docker with RDS CA bundle),
10+
// otherwise fall back to unverified SSL (Trigger.dev, Vercel, other environments).
11+
const hasCABundle = !!process.env.NODE_EXTRA_CA_CERTS;
12+
const ssl = isLocalhost ? undefined : hasCABundle ? true : { rejectUnauthorized: false };
13+
const adapter = new PrismaPg({ connectionString: url, ssl });
1014
return new PrismaClient({ adapter });
1115
}
1216

apps/framework-editor/prisma/client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ const globalForPrisma = global as unknown as { prisma: PrismaClient };
66
function createPrismaClient(): PrismaClient {
77
const url = process.env.DATABASE_URL!;
88
const isLocalhost = /localhost|127\.0\.0\.1|::1/.test(url);
9-
const adapter = new PrismaPg({ connectionString: url, ssl: isLocalhost ? undefined : true });
9+
// Use verified SSL when NODE_EXTRA_CA_CERTS is set (Docker with RDS CA bundle),
10+
// otherwise fall back to unverified SSL (Trigger.dev, Vercel, other environments).
11+
const hasCABundle = !!process.env.NODE_EXTRA_CA_CERTS;
12+
const ssl = isLocalhost ? undefined : hasCABundle ? true : { rejectUnauthorized: false };
13+
const adapter = new PrismaPg({ connectionString: url, ssl });
1014
return new PrismaClient({ adapter });
1115
}
1216

apps/portal/prisma/client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ const globalForPrisma = global as unknown as { prisma: PrismaClient };
66
function createPrismaClient(): PrismaClient {
77
const url = process.env.DATABASE_URL!;
88
const isLocalhost = /localhost|127\.0\.0\.1|::1/.test(url);
9-
const adapter = new PrismaPg({ connectionString: url, ssl: isLocalhost ? undefined : true });
9+
// Use verified SSL when NODE_EXTRA_CA_CERTS is set (Docker with RDS CA bundle),
10+
// otherwise fall back to unverified SSL (Trigger.dev, Vercel, other environments).
11+
const hasCABundle = !!process.env.NODE_EXTRA_CA_CERTS;
12+
const ssl = isLocalhost ? undefined : hasCABundle ? true : { rejectUnauthorized: false };
13+
const adapter = new PrismaPg({ connectionString: url, ssl });
1014
return new PrismaClient({ adapter });
1115
}
1216

packages/db/scripts/combine-schemas.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ const globalForPrisma = global as unknown as { prisma: PrismaClient };
5757
function createPrismaClient(): PrismaClient {
5858
const url = process.env.DATABASE_URL!;
5959
const isLocalhost = /localhost|127\\.0\\.0\\.1|::1/.test(url);
60-
const adapter = new PrismaPg({ connectionString: url, ssl: isLocalhost ? undefined : true });
60+
const hasCABundle = !!process.env.NODE_EXTRA_CA_CERTS;
61+
const ssl = isLocalhost ? undefined : hasCABundle ? true : { rejectUnauthorized: false };
62+
const adapter = new PrismaPg({ connectionString: url, ssl });
6163
return new PrismaClient({ adapter });
6264
}
6365

packages/db/src/client.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ const globalForPrisma = global as unknown as { prisma: PrismaClient };
66
function createPrismaClient(): PrismaClient {
77
const url = process.env.DATABASE_URL!;
88
const isLocalhost = /localhost|127\.0\.0\.1|::1/.test(url);
9-
const adapter = new PrismaPg({ connectionString: url, ssl: isLocalhost ? undefined : true });
9+
// Use verified SSL when NODE_EXTRA_CA_CERTS is set (Docker with RDS CA bundle),
10+
// otherwise fall back to unverified SSL (Trigger.dev, Vercel, other environments).
11+
const hasCABundle = !!process.env.NODE_EXTRA_CA_CERTS;
12+
const ssl = isLocalhost ? undefined : hasCABundle ? true : { rejectUnauthorized: false };
13+
const adapter = new PrismaPg({ connectionString: url, ssl });
1014
return new PrismaClient({ adapter });
1115
}
1216

0 commit comments

Comments
 (0)