mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 08:58:25 +01:00
The /whitepaper page reads content/whitepaper.md from process.cwd() at runtime. That dir was supplied by a postbuild copy (deploy-local.sh) which raced with next's standalone recreate, intermittently leaving .next/standalone/content missing → /whitepaper 500 → repeated pre-push smoke failures that blocked unrelated pushes. Add ./content/** to outputFileTracingIncludes for /whitepaper so Next bundles it into the standalone build output deterministically (no postbuild-copy race). Verified after a clean rebuild: content present in standalone, /whitepaper 200, service cwd is the live standalone. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
87 lines
3.9 KiB
TypeScript
87 lines
3.9 KiB
TypeScript
import type { NextConfig } from "next";
|
|
import { execSync } from "node:child_process";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
// Build-time version stamp — baked into the client bundle as NEXT_PUBLIC_* so
|
|
// the UI can show "which build is this" under the logo (and a changelog link).
|
|
// SHA is the precise build identity; the package version is the marketing
|
|
// semver. Computed once at build; on the box the push-deploy hook builds
|
|
// locally then rsyncs, so the SHA reflects the deployed commit. The desktop
|
|
// (Fleet Runner) version is read separately at runtime from the User-Agent
|
|
// (`FleetRunner/<ver>`, set in desktop/src/main/index.ts).
|
|
function buildSha(): string {
|
|
if (process.env.FLEETCROWN_BUILD_SHA) return process.env.FLEETCROWN_BUILD_SHA;
|
|
try {
|
|
return execSync("git rev-parse --short HEAD", { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
} catch {
|
|
return "dev";
|
|
}
|
|
}
|
|
const PKG_VERSION = (() => {
|
|
try { return (JSON.parse(readFileSync("./package.json", "utf8")) as { version: string }).version; }
|
|
catch { return "0.0.0"; }
|
|
})();
|
|
|
|
const nextConfig: NextConfig = {
|
|
output: "standalone",
|
|
env: {
|
|
NEXT_PUBLIC_APP_VERSION: PKG_VERSION,
|
|
NEXT_PUBLIC_BUILD_SHA: buildSha(),
|
|
},
|
|
async headers() {
|
|
return [
|
|
{
|
|
source: "/sw.js",
|
|
headers: [
|
|
{ key: "Cache-Control", value: "no-cache, no-store, must-revalidate" },
|
|
{ key: "Service-Worker-Allowed", value: "/" },
|
|
],
|
|
},
|
|
];
|
|
},
|
|
outputFileTracingExcludes: {
|
|
"/api/agent/launch": ["./next.config.ts"],
|
|
// CRITICAL — without this glob every serverless function deployed to
|
|
// Vercel exceeded the 250 MB unzipped limit and the whole deploy
|
|
// failed silently. The desktop/ subtree is the Electron app + its
|
|
// node_modules + bundled Zellij (~35 MB) + AppImage build artifacts.
|
|
// It has NOTHING to do with the web app, but Next.js's output:
|
|
// "standalone" tracer was copying the whole tree into every function
|
|
// on the off chance any web code happened to import something from
|
|
// `desktop/`. Nothing does. The "*" key applies the exclusion to
|
|
// every route bundle.
|
|
"*": [
|
|
"./desktop/**",
|
|
// The v0.6 event bridge is its own Node service that runs on Oracle
|
|
// (or wherever we host Postgres) — not on Vercel. Excluding the
|
|
// directory keeps its node_modules out of every serverless function
|
|
// bundle. Same lesson as desktop/.
|
|
"./bridge/**",
|
|
// AppImage extraction artifacts (e.g., from `./Fleet-Runner-*.AppImage
|
|
// --appimage-extract`) drop a `squashfs-root/` tree containing the
|
|
// full unpacked Electron app (~300 MB). It also has nothing to do
|
|
// with the web app; tracing was including it whenever a dev had
|
|
// extracted an AppImage in the repo root for inspection.
|
|
"./squashfs-root/**",
|
|
],
|
|
},
|
|
outputFileTracingIncludes: {
|
|
// Serves the @fleetcrown/agent CLI script to new customers (the package
|
|
// isn't published to npm yet and the repo is private). Without explicit
|
|
// tracing, Vercel would tree-shake the file out of the deployment bundle.
|
|
"/api/agent/install": ["./packages/agent/bin/**"],
|
|
// Markdown content read at runtime via process.cwd()/content (e.g. the
|
|
// /whitepaper page). Tracing it INTO the standalone build makes it
|
|
// deterministically present at .next/standalone/content/, instead of
|
|
// relying on the postbuild deploy-local.sh copy — which raced with the
|
|
// standalone recreate and intermittently left /whitepaper 500-ing
|
|
// (ENOENT content/whitepaper.md), repeatedly failing the pre-push smoke.
|
|
"/whitepaper": ["./content/**"],
|
|
// /api/agent/daemon's bash + python bundle entries are gone — Session 4 of
|
|
// killing-the-bash-daemon (2026-06-11) deleted the source files and the
|
|
// route now returns 410 Gone pointing at /download for Fleet Runner.
|
|
},
|
|
};
|
|
|
|
export default nextConfig;
|