From d1937010e843fe79501db91e9be2e8ed63448e25 Mon Sep 17 00:00:00 2001 From: TheDemonTuan Date: Tue, 25 Aug 2026 13:46:34 +0700 Subject: [PATCH 1/2] fix(docker-bun): make Bun image install and SQLite startup reliable --- Dockerfile.bun | 34 ++++++++++++------- .../11469-dockerfile-bun-install-sqlite.md | 1 + 2 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 changelog.d/fixes/11469-dockerfile-bun-install-sqlite.md diff --git a/Dockerfile.bun b/Dockerfile.bun index bb547ce210da..323296ea1894 100644 --- a/Dockerfile.bun +++ b/Dockerfile.bun @@ -19,21 +19,28 @@ RUN apt-get update \ FROM base AS builder WORKDIR /app -COPY . . +# Cache dependency layer +COPY package.json bun.lock* pnpm-workspace.yaml* ./ +COPY open-sse/package.json ./open-sse/package.json +COPY packages/ ./packages/ + +# Root postinstall helpers needed during bun install lifecycle +COPY scripts/build/ ./scripts/build/ +COPY scripts/dev/sync-env.mjs ./scripts/dev/sync-env.mjs # Fast Bun native package install RUN bun install --include=optional --quiet -# Compile native better-sqlite3 Node-API addon under Bun -RUN if [ -d "node_modules/better-sqlite3" ]; then \ - (cd node_modules/better-sqlite3 && bunx node-gyp rebuild); \ - fi - # Fetch tls-client-node native binary if script exists -RUN if [ -f "node_modules/tls-client-node/scripts/postinstall.js" ]; then \ +RUN if [ -f "node_modules/tls-client-node/scripts/postinstall.js" ] && [ ! -d "node_modules/tls-client-node/bin" ]; then \ bun node_modules/tls-client-node/scripts/postinstall.js || true; \ fi +# Smoke check native database driver used by Bun (bun:sqlite) +RUN bun -e "import { Database } from 'bun:sqlite'; const db = new Database(':memory:'); db.query('SELECT 1 AS ok').get(); db.close(); console.log('bun:sqlite smoke: OK');" + +COPY . . + # Disable Turbopack for Bun builder stage (Turbopack V8 internal worker bindings require Node) ENV OMNIROUTE_USE_TURBOPACK=0 @@ -65,6 +72,7 @@ RUN apt-get update \ libsecret-1-0 \ ca-certificates \ curl \ + sqlite3 \ && rm -rf /var/lib/apt/lists/* ENV NODE_ENV=production @@ -76,11 +84,12 @@ ENV DATA_DIR=/app/data RUN mkdir -p /app/data COPY --from=builder /app/.build/next/standalone ./ -COPY --from=builder /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3 -ENV OMNIROUTE_MIGRATIONS_DIR=/app/migrations - COPY --from=builder /app/scripts/dev/healthcheck.mjs ./healthcheck.mjs +RUN chown -R bun:bun /app /app/data + +USER bun + EXPOSE 20128 HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ @@ -141,6 +150,7 @@ RUN apt-get update \ ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 ENV PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium -# Return to the base image non-root user after the apt install (mirrors the -# Node Dockerfile runner-web stage, which re-asserts USER node). +# Drop back to default non-root user USER bun + +ENTRYPOINT ["bun", "dev/run-standalone.mjs"] diff --git a/changelog.d/fixes/11469-dockerfile-bun-install-sqlite.md b/changelog.d/fixes/11469-dockerfile-bun-install-sqlite.md new file mode 100644 index 000000000000..70b3e2f02984 --- /dev/null +++ b/changelog.d/fixes/11469-dockerfile-bun-install-sqlite.md @@ -0,0 +1 @@ +- **fix(docker-bun):** make `Dockerfile.bun` install reliable with pre-install script helpers and native `bun:sqlite` smoke check ([#11469](https://github.com/diegosouzapw/OmniRoute/pull/11469)) — thanks @TheDemonTuan From aedd4a57ea3689e8ff62849e30805b2fe7c0f777 Mon Sep 17 00:00:00 2001 From: TheDemonTuan Date: Tue, 25 Aug 2026 13:47:09 +0700 Subject: [PATCH 2/2] docs(changelog): update fragment to match PR #11470 --- ...install-sqlite.md => 11470-dockerfile-bun-install-sqlite.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename changelog.d/fixes/{11469-dockerfile-bun-install-sqlite.md => 11470-dockerfile-bun-install-sqlite.md} (70%) diff --git a/changelog.d/fixes/11469-dockerfile-bun-install-sqlite.md b/changelog.d/fixes/11470-dockerfile-bun-install-sqlite.md similarity index 70% rename from changelog.d/fixes/11469-dockerfile-bun-install-sqlite.md rename to changelog.d/fixes/11470-dockerfile-bun-install-sqlite.md index 70b3e2f02984..0d8a165134d4 100644 --- a/changelog.d/fixes/11469-dockerfile-bun-install-sqlite.md +++ b/changelog.d/fixes/11470-dockerfile-bun-install-sqlite.md @@ -1 +1 @@ -- **fix(docker-bun):** make `Dockerfile.bun` install reliable with pre-install script helpers and native `bun:sqlite` smoke check ([#11469](https://github.com/diegosouzapw/OmniRoute/pull/11469)) — thanks @TheDemonTuan +- **fix(docker-bun):** make `Dockerfile.bun` install reliable with pre-install script helpers and native `bun:sqlite` smoke check ([#11470](https://github.com/diegosouzapw/OmniRoute/pull/11470)) — thanks @TheDemonTuan