fix: run API on bookworm with debian Prisma engine

This commit is contained in:
mahmood
2026-09-10 14:45:47 +03:30
parent 88bb7b1fbf
commit 7d93507089
8 changed files with 28 additions and 5 deletions
+19
View File
@@ -9,9 +9,13 @@ const {
rmSync,
cpSync,
realpathSync,
readdirSync,
} = require('fs');
const path = require('path');
// Only this engine ships to Docker; see apps/api/Dockerfile (bookworm/OpenSSL 3).
const RUNTIME_ENGINE = 'libquery_engine-debian-openssl-3.0.x.so.node';
const root = path.join(__dirname, '..');
const config = require(path.join(root, 'esbuild.release.config.cjs'));
const releaseDir = path.join(root, 'release');
@@ -44,6 +48,21 @@ function copyPrismaIntoRelease() {
const prismaEngineDest = path.join(vendorDir, '.prisma', 'client');
mkdirSync(path.dirname(prismaEngineDest), { recursive: true });
cpSync(realpathSync(prismaEngineSrc), prismaEngineDest, { recursive: true });
// Drop engines for other platforms (local Windows dll, stale musl builds) so the
// committed artifact stays small.
for (const name of readdirSync(prismaEngineDest)) {
const isEngine = name.endsWith('.so.node') || name.endsWith('.dll.node');
if (isEngine && name !== RUNTIME_ENGINE) {
rmSync(path.join(prismaEngineDest, name), { force: true });
}
}
if (!existsSync(path.join(prismaEngineDest, RUNTIME_ENGINE))) {
throw new Error(
`${RUNTIME_ENGINE} تولید نشد. binaryTargets در prisma/schema.prisma را بررسی کنید.`,
);
}
}
async function main() {