Some checks failed
Deploy MineGeo to Dokploy / deploy (push) Failing after 7m39s
44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
import { spawnSync } from "node:child_process";
|
|
|
|
// Release each child's memory before starting the next expensive build phase.
|
|
// In particular, do not type-check while a compiled bundler is still resident.
|
|
function run(label, args, typechecked = false) {
|
|
console.log(`[build:docker] ${label}`);
|
|
const started = Date.now();
|
|
const child = spawnSync(process.execPath, args, {
|
|
stdio: "inherit",
|
|
env: {
|
|
...process.env,
|
|
NODE_OPTIONS: "--max-old-space-size=640",
|
|
NEXT_TELEMETRY_DISABLED: "1",
|
|
MINEGEO_DOCKER_TYPECHECKED: typechecked ? "1" : "0",
|
|
},
|
|
});
|
|
if (child.error) throw child.error;
|
|
if (child.status !== 0) {
|
|
console.error(
|
|
`[build:docker] ${label} failed (${child.signal || `exit ${child.status}`}).`,
|
|
);
|
|
process.exit(child.status || 1);
|
|
}
|
|
console.log(
|
|
`[build:docker] ${label} finished in ${Math.round((Date.now() - started) / 1000)}s.`,
|
|
);
|
|
}
|
|
|
|
run("Clean build cache", ["scripts/clean-build.mjs"]);
|
|
run("Generate route types", ["node_modules/next/dist/bin/next", "typegen"]);
|
|
run("Check TypeScript", [
|
|
"node_modules/typescript/bin/tsc",
|
|
"--noEmit",
|
|
"--incremental",
|
|
"false",
|
|
]);
|
|
// Type errors fail the preceding step. Only this invocation skips the duplicate
|
|
// check; regular npm run build still performs Next.js's normal type checking.
|
|
run(
|
|
"Compile production application",
|
|
["node_modules/next/dist/bin/next", "build", "--webpack"],
|
|
true,
|
|
);
|