Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

perf(cloud): tighten Docker build, compose healthcheck, and Cloud Home compile cache

milind-sonidaa5d2e32543
diff --git a/.dockerignore b/.dockerignore
index 0abdc1b89b..5db2495bf9 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,17 +1,62 @@
+# Dependencies and build outputs
node_modules
**/node_modules
dist
dist-server
dist-electron
+dist-native
+dist-companion
+dist-updater
release
+coverage
+test-results
+tmp
+.omb-scratch
+
+# VCS, editor, agent, and local secrets
.git
.github
.claude
-*.dmg
-*.zip
-*.log
-electron/resources/cloudflared*
-.omb-scratch
+.agents
+.gemini
+.omx
+.t3
+.codex-*
.env
**/.env
**/.env.*
+*.dmg
+*.zip
+*.log
+
+# Workspaces, platforms, and docs not used by the server/cloud-home Docker build
+# (keep workspace manifests needed by `pnpm install --frozen-lockfile`)
+apps/docs/**
+!apps/docs/package.json
+cloudflare/**
+!cloudflare/control-plane/package.json
+# Keep only the tunnel guardian files bundled by scripts/bundle-server.mjs
+electron/**
+!electron/managed-companion-guardian-main.mjs
+!electron/managed-companion-guardian.mjs
+!electron/companion-origin-gateway.mjs
+ios
+android
+companion
+relay
+docs
+evals
+third_party
+integrations
+
+# Test files, dev previews, and translation hash metadata (~11 MB, build-irrelevant)
+**/*.test.ts
+**/*.test.tsx
+**/*.test.mjs
+**/*.node-test.mjs
+src/locales/source-hashes.json
+*-preview.html
+chief-*.html
+src/*-preview.tsx
+src/chief-*.tsx
+scripts/testing/*-preview.tsx
diff --git a/compose.yaml b/compose.yaml
index 4b68c56cc1..c83d0fd778 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -33,12 +33,8 @@ services:
# The licence; a license.key in the data folder (/data/.openmausbot) is read too, and the newer one wins.
OMB_LICENSE_KEY: ${OMB_LICENSE_KEY:-}
healthcheck:
- test:
- - CMD
- - node
- - -e
- - "fetch('http://127.0.0.1:8799/api/health', { signal: AbortSignal.timeout(4000) }).then(async r => { if (!r.ok || !(await r.text()).includes('openmausbot')) process.exit(1); }).catch(() => process.exit(1))"
- interval: 15s
+ test: ["CMD-SHELL", "curl -sf http://127.0.0.1:8799/api/health | grep -q openmausbot"]
+ interval: 30s
timeout: 5s
start_period: 30s
retries: 5
diff --git a/scripts/bundle-server.mjs b/scripts/bundle-server.mjs
index 002e75d3f0..f7e9c87325 100644
--- a/scripts/bundle-server.mjs
+++ b/scripts/bundle-server.mjs
@@ -9,6 +9,11 @@ import { serverLocalePlugin } from "./server-locale-plugin.mjs";
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const server = join(root, "server");
+const outdir = join(root, "dist-server");
+
+// Clear stale bundles or intermediate files from earlier builds so Docker and
+// desktop packages only ship the current self-contained entry points.
+rmSync(outdir, { recursive: true, force: true });
// yaml's Node export is CommonJS with dynamic requires that cannot run once
// inlined into ESM; its browser export is the same parser without them.
@@ -45,8 +50,7 @@ const ENTRY_POINTS = [
"cloud-backup-db-snapshot.ts",
// the container image's entry point
"server-launcher.ts",
- // Imported directly by the packaged smoke probes. An explicit root sibling,
- // because tsc may emit its own copy under dist-server/server/.
+ // Imported directly by the packaged smoke probes.
"proxy-paths.ts",
"local-computer.ts",
"local-computer-proxy.ts",
@@ -78,12 +82,11 @@ await build({
target: "node20",
format: "esm",
outbase: server,
- outdir: join(root, "dist-server"),
+ outdir,
// Function names stay in stack traces. Node prints a whole source line with an uncaught error, so no line may be long.
minifyWhitespace: true,
minifySyntax: true,
lineLimit: 500,
- // Written after tsc, replacing its output for these entry points.
allowOverwrite: true,
logLevel: "info",
plugins: [yamlEsmPlugin, serverLocalePlugin],
@@ -98,7 +101,7 @@ await build({
platform: "node",
target: "node20",
format: "esm",
- outfile: join(root, "dist-server", "mcp-server.js"),
+ outfile: join(outdir, "mcp-server.js"),
allowOverwrite: true,
logLevel: "info",
plugins: [serverLocalePlugin],
@@ -112,7 +115,7 @@ await build({
platform: "node",
target: "node20",
format: "esm",
- outfile: join(root, "dist-server", "tunnel-guardian.js"),
+ outfile: join(outdir, "tunnel-guardian.js"),
allowOverwrite: true,
logLevel: "info",
});
@@ -125,7 +128,7 @@ await build({
platform: "node",
target: "node20",
format: "esm",
- outfile: join(root, "dist-server", "prepare-cloudflared.js"),
+ outfile: join(outdir, "prepare-cloudflared.js"),
allowOverwrite: true,
logLevel: "info",
});
@@ -140,33 +143,33 @@ if (existsSync(join(root, "enterprise", "server", "index.ts"))) {
platform: "node",
target: "node20",
format: "esm",
- outfile: join(root, "dist-server", "enterprise", "server", "index.js"),
+ outfile: join(outdir, "enterprise", "server", "index.js"),
allowOverwrite: true,
logLevel: "info",
plugins: [serverLocalePlugin],
});
- copyFileSync(join(root, "enterprise", "LICENSE"), join(root, "dist-server", "enterprise", "LICENSE"));
+ copyFileSync(join(root, "enterprise", "LICENSE"), join(outdir, "enterprise", "LICENSE"));
}
// The packaged desktop and the container launcher run this bootstrap to turn on Node's compile cache.
// Copied, not bundled: esbuild would inline index.js into it.
-copyFileSync(join(root, "scripts", "desktop-server-entry.mjs"), join(root, "dist-server", "desktop-entry.mjs"));
+copyFileSync(join(root, "scripts", "desktop-server-entry.mjs"), join(outdir, "desktop-entry.mjs"));
// The model catalog snapshot (server/model-catalog/catalog.ts) is read from
// disk, not inlined: 1.5 MB of JSON has no place in index.js. The bundle looks
// for it under model-catalog/ beside itself. Its MIT notice is inside the file.
-const catalogSnapshot = join(root, "dist-server", "model-catalog", "models-dev.snapshot.json");
+const catalogSnapshot = join(outdir, "model-catalog", "models-dev.snapshot.json");
mkdirSync(dirname(catalogSnapshot), { recursive: true });
copyFileSync(join(server, "model-catalog", "models-dev.snapshot.json"), catalogSnapshot);
// The starter apps' pages (server/local-apps/starters.ts), read from local-apps/starters/ beside the bundle.
-cpSync(join(server, "local-apps", "starters"), join(root, "dist-server", "local-apps", "starters"), { recursive: true });
+cpSync(join(server, "local-apps", "starters"), join(outdir, "local-apps", "starters"), { recursive: true });
// Pi loads this through its own jiti and supplies TypeBox. Inline our local
// policy module so the extension also works without the source checkout;
// keep the Pi-owned dependency external and retain the .ts loading contract.
const piMcpExtSrc = join(server, "drivers", "pi-mcp-extension.ts");
-const piMcpExtDest = join(root, "dist-server", "drivers", "pi-mcp-extension.ts");
+const piMcpExtDest = join(outdir, "drivers", "pi-mcp-extension.ts");
mkdirSync(dirname(piMcpExtDest), { recursive: true });
await build({ entryPoints: [piMcpExtSrc], outfile: piMcpExtDest, bundle: true,
platform: "node", target: "node24", format: "esm", external: ["typebox"], });
@@ -176,8 +179,4 @@ await build({ entryPoints: [piMcpExtSrc], outfile: piMcpExtDest, bundle: true,
// The version rides along: an image ships dist-server without the root
// package.json, and the server reports this one (server/environment.ts).
const { version } = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
-writeFileSync(join(root, "dist-server", "package.json"), `${JSON.stringify({ type: "module", version })}\n`);
-
-// tsc copies the language packs server/server-lines.ts imports (13 MB) beside its own output. The bundles above carry
-// the server's keys, so nothing reads the copies.
-rmSync(join(root, "dist-server", "src", "locales"), { recursive: true, force: true });
+writeFileSync(join(outdir, "package.json"), `${JSON.stringify({ type: "module", version })}\n`);
diff --git a/server/cloud-home-start.ts b/server/cloud-home-start.ts
index b4a0dadb6d..87906ab628 100644
--- a/server/cloud-home-start.ts
+++ b/server/cloud-home-start.ts
@@ -269,8 +269,10 @@ export function cloudHomeChildEnvironments(config: CloudHomeConfig, env: NodeJS.
const dataDir = cloudHomeDataDir(env, home);
const server: NodeJS.ProcessEnv = {
...allowed, HOME: home, OMB_DATA_DIR: dataDir,
- // Node keys the entries by its own version and the file's hash, so a stale entry is never used after an image upgrade.
- NODE_COMPILE_CACHE: posix.join(dataDir, "cache", "node-compile"),
+ // desktop-entry.mjs enables Node's compile cache in-process (OMB_SERVER_COMPILE_CACHE) without setting
+ // NODE_COMPILE_CACHE, so child Node processes (engine CLIs, MCP servers, bot shells) never inherit it,
+ // and flushes + prunes stale Node-version caches automatically.
+ OMB_SERVER_COMPILE_CACHE: posix.join(dataDir, "cache", "node-compile"),
OMB_PORT: "8799", OMB_WEBHOOK_PORT: "8800", OMB_PUBLIC_URL: config.publicOrigin,
OMB_WEBHOOK_PUBLIC_URL: env.OMB_WEBHOOK_PUBLIC_URL || config.publicOrigin,
[CLOUD_SECRETS_FD_ENV]: String(SECRETS_FD),
@@ -498,10 +500,11 @@ export function startCloudHome(processEnv: NodeJS.ProcessEnv = process.env) {
// The clock (server/cloud-clock-keeper.ts): root keeps it right after a resume the provider left it behind on. Root only.
const keeper = ids && process.platform === "linux" ? startClockKeeper(config.adminOrigin) : null;
const policy = restartPolicy();
+ const serverEntry = existsSync(join(here, "desktop-entry.mjs")) ? join(here, "desktop-entry.mjs") : join(here, "index.js");
const runServer = () => {
if (stopping) return;
watch(inServerGroup(() => spawnWithOomScore(OOM_SCORE.server, () => {
- const child = spawnWithSecrets(process.execPath, [...heapSizeArgs(boxMemory().cgroupLimit, server.NODE_OPTIONS), join(here, "index.js")], server, secrets, ids, false, Boolean(keeper));
+ const child = spawnWithSecrets(process.execPath, [...heapSizeArgs(boxMemory().cgroupLimit, server.NODE_OPTIONS), serverEntry], server, secrets, ids, false, Boolean(keeper));
const pipe = child.stdio[CLOCK_FD];
if (keeper && pipe instanceof Readable) keeper.listen(pipe);
return child;
diff --git a/server/cloud-home.test.ts b/server/cloud-home.test.ts
index c94deffff3..7b93d482c9 100644
--- a/server/cloud-home.test.ts
+++ b/server/cloud-home.test.ts
@@ -390,8 +390,9 @@ it("gives the edge only its routing name and the server the contract, never a ga
OMB_CLOUD_AI_TOKEN: `omb_ai_${"a".repeat(43)}` };
const config = cloudHomeConfiguration(withGateway())!;
const { server, edge, secrets } = cloudHomeChildEnvironments(config, { ...withGateway(), ...relay, PATH: "/usr/bin" }, "/data");
- expect(server).toMatchObject({ HOME: "/data", OMB_DATA_DIR: "/data/.openmausbot", NODE_COMPILE_CACHE: "/data/.openmausbot/cache/node-compile", OMB_PORT: "8799", OMB_WEBHOOK_PORT: "8800",
+ expect(server).toMatchObject({ HOME: "/data", OMB_DATA_DIR: "/data/.openmausbot", OMB_SERVER_COMPILE_CACHE: "/data/.openmausbot/cache/node-compile", OMB_PORT: "8799", OMB_WEBHOOK_PORT: "8800",
OMB_PUBLIC_URL: "https://omb-u-1a2b3c4d5e6f.fly.dev", OMB_WEBHOOK_PUBLIC_URL: "https://omb-u-1a2b3c4d5e6f.fly.dev", OMB_CLOUD_SECRETS_FD: "3" });
+ expect(server).not.toHaveProperty("NODE_COMPILE_CACHE");
for (const key of CLOUD_IGNORED_KEYS) expect(server).not.toHaveProperty(key);
// The bot box and image-engines switches reach the server; an unknown name does not.
expect(cloudHomeChildEnvironments(config, { ...withGateway(), PATH: "/usr/bin", OMB_BOT_BOX: "0", OMB_IMAGE_ENGINES: "1", OMB_SOMETHING_ELSE: "x" }, "/data").server).toMatchObject({ OMB_BOT_BOX: "0", OMB_IMAGE_ENGINES: "1" });
@@ -491,7 +492,7 @@ it("holds requests at the edge while the server starts only when the Admin asked
it("hands the server the tool cache switch, and moves no cache of the server's own", () => {
const config = cloudHomeConfiguration(withGateway())!;
const server = cloudHomeChildEnvironments(config, { ...withGateway(), PATH: "/usr/bin", OMB_CACHE_ROOT: "on", OMB_CACHE_SWEEP: "on", OMB_CACHE_CAP_TOOLS: "4G", OMB_CACHE_CAP_APP: "1G" }, "/data").server;
- expect(server).toMatchObject({ OMB_CACHE_ROOT: "on", OMB_CACHE_SWEEP: "on", OMB_CACHE_CAP_TOOLS: "4G", OMB_CACHE_CAP_APP: "1G", HOME: "/data", NODE_COMPILE_CACHE: "/data/.openmausbot/cache/node-compile" });
+ expect(server).toMatchObject({ OMB_CACHE_ROOT: "on", OMB_CACHE_SWEEP: "on", OMB_CACHE_CAP_TOOLS: "4G", OMB_CACHE_CAP_APP: "1G", HOME: "/data", OMB_SERVER_COMPILE_CACHE: "/data/.openmausbot/cache/node-compile" });
// Only the bot box adds the tools' variables (bot-box/tool-caches.ts), for each box's own HOME.
for (const name of ["npm_config_cache", "PIP_CACHE_DIR", "UV_CACHE_DIR", "HF_HUB_CACHE", "XDG_CACHE_HOME"]) expect(server).not.toHaveProperty(name);
});
diff --git a/src/styles.css b/src/styles.css
index 811eb5364c..6ebb8e601e 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -1,4 +1,9 @@
-@import "tailwindcss";
+@import "tailwindcss" source("../src");
+@source "../index.html";
+@source "../rail.html";
+@source not "./locales";
+@source not "./**/*.test.ts";
+@source not "./**/*.test.tsx";
@import "@fontsource-variable/inter";
@import "@fontsource-variable/geist";
@import "@fontsource-variable/geist-mono";
diff --git a/tsconfig.json b/tsconfig.json
index 6d3b9414f5..6bdfb3e9f3 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -19,5 +19,6 @@
"@/*": ["./src/*"]
}
},
- "include": ["src", "vite.config.ts"]
+ "include": ["src", "vite.config.ts"],
+ "exclude": ["src/locales/source-hashes.json"]
}
diff --git a/tsconfig.server.build.json b/tsconfig.server.build.json
index 2a3f9a457c..e235502e14 100644
--- a/tsconfig.server.build.json
+++ b/tsconfig.server.build.json
@@ -1,11 +1,7 @@
{
"extends": "./tsconfig.server.json",
"compilerOptions": {
- "noEmit": false,
- "outDir": "dist-server",
- "rewriteRelativeImportExtensions": true,
- "declaration": false,
- "sourceMap": false
+ "noEmit": true
},
"exclude": [
"server/**/*.test.ts",