docker image to alpine, reduce size, compile scripts, entrypoint for alpine
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
|
||||
console.log('📦 Building TypeScript database scripts...');
|
||||
|
||||
// Create dist directory
|
||||
const distDir = path.join(__dirname, 'dist');
|
||||
if (!fs.existsSync(distDir)) {
|
||||
fs.mkdirSync(distDir, { recursive: true });
|
||||
}
|
||||
|
||||
// Bundle scripts with esbuild (available via Next.js)
|
||||
const scripts = [
|
||||
'scripts/check-database.ts',
|
||||
'scripts/setup-database.ts'
|
||||
];
|
||||
|
||||
scripts.forEach(script => {
|
||||
const scriptName = path.basename(script, '.ts');
|
||||
const outFile = path.join(distDir, `${scriptName}.js`);
|
||||
|
||||
console.log(` Building ${script} -> ${outFile}`);
|
||||
|
||||
try {
|
||||
execSync(`npx esbuild ${script} --bundle --platform=node --target=node22 --outfile=${outFile} --external:better-sqlite3`, {
|
||||
stdio: 'pipe'
|
||||
});
|
||||
console.log(` ✅ ${scriptName}.js built successfully`);
|
||||
} catch (error) {
|
||||
console.error(` ❌ Failed to build ${scriptName}:`, error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('🎉 All database scripts built successfully!');
|
||||
Reference in New Issue
Block a user