Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile.bun
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,19 @@ ENV DATA_DIR=/app/data
RUN mkdir -p /app/data

COPY --from=builder /app/.build/next/standalone ./

ENV OMNIROUTE_MIGRATIONS_DIR=/app/migrations

COPY --from=builder /app/scripts/dev/healthcheck.mjs ./healthcheck.mjs

# Bun uses bun:sqlite. Remove every standalone/vendor copy of the Node-only
# addon so no traced chunk can dlopen it and abort the process before fallback.
RUN find /app \
-path '*/node_modules/better-sqlite3' \
-prune \
-exec rm -rf '{}' + \
&& test -z "$(find /app -type f -name 'better_sqlite3.node' -print -quit)"

RUN chown -R bun:bun /app /app/data

USER bun
Expand Down
1 change: 1 addition & 0 deletions changelog.d/fixes/11482-bun-runtime-native-addon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **fix(docker-bun):** remove every vendored `better-sqlite3` native addon from the Bun runtime image so startup cannot abort before the `bun:sqlite` fallback ([#11482](https://github.com/diegosouzapw/OmniRoute/pull/11482)) — thanks @TheDemonTuan
20 changes: 20 additions & 0 deletions tests/unit/build/bun-runtime-native-addon.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";

const dockerfile = readFileSync(new URL("../../../Dockerfile.bun", import.meta.url), "utf8");

test("Bun runner excludes every better-sqlite3 native addon", () => {
assert.doesNotMatch(
dockerfile,
/COPY --from=builder \/app\/node_modules\/better-sqlite3/
);
assert.match(
dockerfile,
/find \/app[\s\S]*-path '\*\/node_modules\/better-sqlite3'[\s\S]*-prune[\s\S]*-exec rm -rf '\{\}' \+/
);
assert.match(
dockerfile,
/test -z "\$\(find \/app -type f -name 'better_sqlite3\.node' -print -quit\)"/
);
});
Loading