fuck stupid ass bun compiling I fucking hate ts

This commit is contained in:
KingKDot
2026-04-27 21:52:35 -05:00
parent 53ea8bdd4b
commit 8232216873
2 changed files with 10 additions and 29 deletions
+7 -7
View File
@@ -115,11 +115,11 @@ RUN mkdir -p certs public data
RUN bun run build:css && bun run vendor \
&& test -s ./public/assets/tailwind.css && test -d ./public/vendor/fontawesome
# Compile a standalone production binary (sharp is external — kept in node_modules)
RUN BUN_TARGET="bun-linux-x64" \
&& if [ "${TARGETARCH}" = "arm64" ]; then BUN_TARGET="bun-linux-arm64"; fi \
&& bun build --production --external sharp src/index.ts \
--compile --target "$BUN_TARGET" --outfile overlord-server
# NOTE: We intentionally do NOT use `bun build --compile` here.
# The compiled standalone binary runs from a virtual bunfs filesystem that
# cannot reliably load native modules like `sharp` from /app/node_modules,
# even when marked --external. Running the TS entrypoint directly with bun
# keeps normal Node-style module resolution and lets sharp load correctly.
# Expose the default port
EXPOSE 5173
@@ -132,5 +132,5 @@ ENV NODE_ENV=production
ENV OVERLORD_ROOT=/app
ENV NODE_PATH=/app/node_modules
# Run the compiled production binary
CMD ["./overlord-server"]
# Run the server directly with bun (no standalone-binary compile step)
CMD ["bun", "run", "src/index.ts"]
+3 -22
View File
@@ -8,28 +8,9 @@ async function getSharp(): Promise<typeof import("sharp") extends { default: inf
try {
_sharp = (await import("sharp")).default as any;
return _sharp!;
} catch (bareErr) {
try {
const fs = await import("node:fs");
const path = await import("node:path");
const url = await import("node:url");
const root = process.env.OVERLORD_ROOT || process.cwd();
const sharpDir = path.join(root, "node_modules", "sharp");
const pkgJsonPath = path.join(sharpDir, "package.json");
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
const entryRel: string =
(pkg.exports && (pkg.exports["."]?.require ?? pkg.exports["."]?.default ?? pkg.exports["."])) ||
pkg.main ||
"lib/index.js";
const entryAbs = path.resolve(sharpDir, typeof entryRel === "string" ? entryRel : "lib/index.js");
const entryUrl = url.pathToFileURL(entryAbs).href;
const mod: any = await import(entryUrl);
_sharp = (mod && (mod.default ?? mod)) as any;
return _sharp!;
} catch (err) {
console.error("[thumbnails] Failed to load sharp module. Thumbnails will be unavailable.", err);
throw err;
}
} catch (err) {
console.error("[thumbnails] Failed to load sharp module. Thumbnails will be unavailable.", err);
throw err;
}
}