FIx some for connect to postgresql۲
This commit is contained in:
@@ -1,15 +1,57 @@
|
||||
/**
|
||||
* باندل تکفایل + نصب Prisma لوکال داخل release/
|
||||
* خروجی کامل برای Docker کپیonly: app.js + prisma + node_modules
|
||||
*
|
||||
* مهم: schema-engine لینوکس هم باید لوکال دانلود شود؛ وگرنه migrate داخل
|
||||
* سرور ایران برای دانلود از binaries.prisma.sh تایماوت میخورد.
|
||||
*/
|
||||
const esbuild = require('esbuild');
|
||||
const { existsSync, mkdirSync, cpSync, writeFileSync, rmSync } = require('fs');
|
||||
const { existsSync, mkdirSync, cpSync, writeFileSync, rmSync, readdirSync } = require('fs');
|
||||
const path = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
const root = path.join(__dirname, '..');
|
||||
const releaseDir = path.join(root, 'release');
|
||||
const config = require(path.join(root, 'esbuild.release.config.cjs'));
|
||||
const LINUX_TARGET = 'debian-openssl-3.0.x';
|
||||
|
||||
async function downloadLinuxEngines() {
|
||||
const fetchEnginePath = path.join(releaseDir, 'node_modules', '@prisma', 'fetch-engine');
|
||||
const enginesVersionPath = path.join(releaseDir, 'node_modules', '@prisma', 'engines-version');
|
||||
const enginesDir = path.join(releaseDir, 'node_modules', '@prisma', 'engines');
|
||||
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
const { download } = require(fetchEnginePath);
|
||||
// eslint-disable-next-line import/no-dynamic-require, global-require
|
||||
const { enginesVersion } = require(enginesVersionPath);
|
||||
const version = enginesVersion;
|
||||
|
||||
|
||||
console.log('در حال دانلود Prisma engines برای', LINUX_TARGET, 'commit=', version);
|
||||
|
||||
await download({
|
||||
binaries: {
|
||||
'schema-engine': enginesDir,
|
||||
'libquery-engine': enginesDir,
|
||||
},
|
||||
binaryTargets: [LINUX_TARGET],
|
||||
version,
|
||||
});
|
||||
|
||||
const files = readdirSync(enginesDir);
|
||||
const schemaEngine = files.find((f) => f.startsWith('schema-engine') && f.includes('debian'));
|
||||
const queryEngine = files.find((f) => f.includes('debian') && f.includes('query'));
|
||||
|
||||
console.log('engines dir:', files.filter((f) => f.includes('engine') || f.includes('debian')).join(', '));
|
||||
|
||||
if (!schemaEngine) {
|
||||
throw new Error(
|
||||
`schema-engine برای ${LINUX_TARGET} دانلود نشد. بدون آن migrate داخل Docker تایماوت میشود.`,
|
||||
);
|
||||
}
|
||||
|
||||
console.log('OK schema-engine:', schemaEngine, queryEngine || '(query via generate)');
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const entry = path.join(root, config.entryPoints[0]);
|
||||
@@ -34,7 +76,6 @@ async function main() {
|
||||
}
|
||||
cpSync(path.join(root, 'prisma'), prismaDest, { recursive: true });
|
||||
|
||||
// entrypoint برای لاگ واضح استارت در Dokploy
|
||||
cpSync(path.join(root, 'docker-entrypoint.sh'), path.join(releaseDir, 'docker-entrypoint.sh'));
|
||||
|
||||
const releasePkg = {
|
||||
@@ -48,20 +89,29 @@ async function main() {
|
||||
};
|
||||
writeFileSync(path.join(releaseDir, 'package.json'), `${JSON.stringify(releasePkg, null, 2)}\n`);
|
||||
|
||||
// نصب و generate کاملاً لوکال — ایمیج Docker دیگر npm/apk نمیزند
|
||||
console.log('در حال npm install داخل release (لوکال)...');
|
||||
execSync('npm install --omit=dev', {
|
||||
cwd: releaseDir,
|
||||
stdio: 'inherit',
|
||||
env: { ...process.env, PRISMA_SKIP_POSTINSTALL_GENERATE: '1' },
|
||||
env: {
|
||||
...process.env,
|
||||
PRISMA_SKIP_POSTINSTALL_GENERATE: '1',
|
||||
PRISMA_CLI_BINARY_TARGETS: LINUX_TARGET,
|
||||
},
|
||||
});
|
||||
|
||||
console.log('در حال prisma generate (باینری لینوکس برای Docker)...');
|
||||
console.log('در حال prisma generate (query engine لینوکس)...');
|
||||
execSync('npx prisma generate --schema=./prisma/schema.prisma', {
|
||||
cwd: releaseDir,
|
||||
stdio: 'inherit',
|
||||
env: {
|
||||
...process.env,
|
||||
PRISMA_CLI_BINARY_TARGETS: LINUX_TARGET,
|
||||
},
|
||||
});
|
||||
|
||||
await downloadLinuxEngines();
|
||||
|
||||
console.log('آمادهی کپیonly:', releaseDir);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user