Refactor Docker entrypoint to run Prisma migrations; update schema

Co-authored-by: dennis <dennis@konkol.net>
This commit is contained in:
Cursor Agent
2026-01-12 15:08:23 +00:00
parent 80f57184c7
commit f1cc398248
7 changed files with 291 additions and 250 deletions

View File

@@ -0,0 +1,40 @@
/**
* Container entrypoint: apply Prisma migrations, then start Next server.
*
* Why:
* - In real deployments you want schema changes applied automatically per deploy.
* - `prisma migrate deploy` is safe to run multiple times (idempotent).
*
* Controls:
* - Set `SKIP_PRISMA_MIGRATE=true` to skip migrations (emergency / debugging).
*/
const { spawnSync } = require("node:child_process");
function run(cmd, args, opts = {}) {
const res = spawnSync(cmd, args, {
stdio: "inherit",
env: process.env,
...opts,
});
if (res.error) {
throw res.error;
}
if (typeof res.status === "number" && res.status !== 0) {
// propagate exit code
process.exit(res.status);
}
}
const skip = String(process.env.SKIP_PRISMA_MIGRATE || "").toLowerCase() === "true";
if (!skip) {
// Avoid relying on `npx` resolution in minimal runtimes.
// We copy `node_modules/prisma` into the runtime image.
run("node", ["node_modules/prisma/build/index.js", "migrate", "deploy"]);
} else {
// eslint-disable-next-line no-console
console.log("SKIP_PRISMA_MIGRATE=true -> skipping prisma migrate deploy");
}
run("node", ["server.js"]);