Copy SQL migration files into dist/ as part of build

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.
This commit is contained in:
2026-05-01 10:49:48 +02:00
parent 88cc98f3cc
commit 4a9f55cdf0
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -0,0 +1,16 @@
// 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}`);
}