4a9f55cdf0
tsc only emits .ts -> .js; non-TypeScript assets like SQL migration files don't make it into dist/ by default. The migration runner reads *.sql from dist/db/migrations/ at runtime in production (relative to the compiled migrate.js), so the missing files surface as a fatal ENOENT on container startup. Fix: small node script (scripts/copy-assets.mjs) using fs.cpSync, invoked after tsc in the build script. Cross-platform, no new dependencies. The script is in the Docker build context but not copied into the runtime stage, so it doesn't bloat the final image. Verified: pnpm build now produces dist/db/migrations/0001_positions.sql.
17 lines
571 B
JavaScript
17 lines
571 B
JavaScript
// Copies non-TypeScript build artifacts into dist/ after tsc.
|
|
// Currently: SQL migration files for the runtime migration runner.
|
|
// tsc only emits .ts → .js; everything else has to be copied explicitly.
|
|
|
|
import { cpSync, existsSync } from 'node:fs';
|
|
|
|
const assets = [{ src: 'src/db/migrations', dest: 'dist/db/migrations' }];
|
|
|
|
for (const { src, dest } of assets) {
|
|
if (!existsSync(src)) {
|
|
console.error(`copy-assets: source missing: ${src}`);
|
|
process.exit(1);
|
|
}
|
|
cpSync(src, dest, { recursive: true });
|
|
console.log(`copy-assets: ${src} -> ${dest}`);
|
|
}
|