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:
+1
-1
@@ -7,7 +7,7 @@
|
||||
"node": ">=22"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc --project tsconfig.json",
|
||||
"build": "tsc --project tsconfig.json && node scripts/copy-assets.mjs",
|
||||
"dev": "tsx watch src/main.ts",
|
||||
"start": "node dist/main.js",
|
||||
"test": "vitest run",
|
||||
|
||||
Reference in New Issue
Block a user