fix: run API on bookworm with debian Prisma engine
This commit is contained in:
@@ -17,7 +17,7 @@ What this produces:
|
|||||||
|
|
||||||
| App | Artifact | Image |
|
| App | Artifact | Image |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| API | `apps/api/release/app.js` (+ Prisma under `release/node_modules`) | `docker.arvancloud.ir/node:20-alpine` |
|
| API | `apps/api/release/app.js` (+ Prisma under `release/vendor`) | `docker.arvancloud.ir/node:20-bookworm` |
|
||||||
| Admin | `apps/admin-panel/dist/` | `docker.arvancloud.ir/nginx:latest` |
|
| Admin | `apps/admin-panel/dist/` | `docker.arvancloud.ir/nginx:latest` |
|
||||||
| User | `apps/user-app/dist/` | `docker.arvancloud.ir/nginx:latest` |
|
| User | `apps/user-app/dist/` | `docker.arvancloud.ir/nginx:latest` |
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -1,13 +1,15 @@
|
|||||||
FROM docker.arvancloud.ir/node:20-bookworm-slim
|
FROM docker.arvancloud.ir/node:20-bookworm
|
||||||
|
|
||||||
# Pre-built on the developer machine:
|
# Pre-built on the developer machine:
|
||||||
# pnpm build:release
|
# pnpm build:release
|
||||||
|
# NOTE: full "bookworm" (not -slim/-alpine) on purpose — Prisma's query engine
|
||||||
|
# links against libssl.so.3, which the slim/alpine variants do not ship, and the
|
||||||
|
# deploy host cannot reach apt/apk mirrors to install it.
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
# Vendored Prisma lives in ./vendor (not node_modules — that path is gitignored)
|
# Vendored Prisma lives in ./vendor (not node_modules — that path is gitignored)
|
||||||
ENV NODE_PATH=/app/vendor
|
ENV NODE_PATH=/app/vendor
|
||||||
# Force Debian OpenSSL 3 engine (bookworm-slim); avoid wrong musl/openssl-1.1 pick
|
|
||||||
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/vendor/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node
|
ENV PRISMA_QUERY_ENGINE_LIBRARY=/app/vendor/.prisma/client/libquery_engine-debian-openssl-3.0.x.so.node
|
||||||
|
|
||||||
COPY release/ ./
|
COPY release/ ./
|
||||||
|
|||||||
+2
-1
@@ -434,7 +434,8 @@ const config = {
|
|||||||
"sourceFilePath": "C:\\App\\gold-bank\\apps\\api\\prisma\\schema.prisma"
|
"sourceFilePath": "C:\\App\\gold-bank\\apps\\api\\prisma\\schema.prisma"
|
||||||
},
|
},
|
||||||
"relativeEnvPaths": {
|
"relativeEnvPaths": {
|
||||||
"rootEnvPath": null
|
"rootEnvPath": null,
|
||||||
|
"schemaEnvPath": "../../../../../../apps/api/.env"
|
||||||
},
|
},
|
||||||
"relativePath": "../../../../../../apps/api/prisma",
|
"relativePath": "../../../../../../apps/api/prisma",
|
||||||
"clientVersion": "5.22.0",
|
"clientVersion": "5.22.0",
|
||||||
|
|||||||
+2
-1
@@ -435,7 +435,8 @@ const config = {
|
|||||||
"sourceFilePath": "C:\\App\\gold-bank\\apps\\api\\prisma\\schema.prisma"
|
"sourceFilePath": "C:\\App\\gold-bank\\apps\\api\\prisma\\schema.prisma"
|
||||||
},
|
},
|
||||||
"relativeEnvPaths": {
|
"relativeEnvPaths": {
|
||||||
"rootEnvPath": null
|
"rootEnvPath": null,
|
||||||
|
"schemaEnvPath": "../../../../../../apps/api/.env"
|
||||||
},
|
},
|
||||||
"relativePath": "../../../../../../apps/api/prisma",
|
"relativePath": "../../../../../../apps/api/prisma",
|
||||||
"clientVersion": "5.22.0",
|
"clientVersion": "5.22.0",
|
||||||
|
|||||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -9,9 +9,13 @@ const {
|
|||||||
rmSync,
|
rmSync,
|
||||||
cpSync,
|
cpSync,
|
||||||
realpathSync,
|
realpathSync,
|
||||||
|
readdirSync,
|
||||||
} = require('fs');
|
} = require('fs');
|
||||||
const path = require('path');
|
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 root = path.join(__dirname, '..');
|
||||||
const config = require(path.join(root, 'esbuild.release.config.cjs'));
|
const config = require(path.join(root, 'esbuild.release.config.cjs'));
|
||||||
const releaseDir = path.join(root, 'release');
|
const releaseDir = path.join(root, 'release');
|
||||||
@@ -44,6 +48,21 @@ function copyPrismaIntoRelease() {
|
|||||||
const prismaEngineDest = path.join(vendorDir, '.prisma', 'client');
|
const prismaEngineDest = path.join(vendorDir, '.prisma', 'client');
|
||||||
mkdirSync(path.dirname(prismaEngineDest), { recursive: true });
|
mkdirSync(path.dirname(prismaEngineDest), { recursive: true });
|
||||||
cpSync(realpathSync(prismaEngineSrc), 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() {
|
async function main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user