feat: ship prebuilt better-sqlite3 binaries for CentOS/Alpine compatibility#81
feat: ship prebuilt better-sqlite3 binaries for CentOS/Alpine compatibility#81Lets7512 wants to merge 3 commits intomksglu:mainfrom
Conversation
…bility Add runtime fallback to prebuilt better_sqlite3.node binaries when the default native binding fails to load (e.g. glibc mismatch on CentOS 7/8). Uses better-sqlite3's nativeBinding option — no extra dependencies needed. - db-base.ts: findPrebuildPath() + SQLiteBase constructor fallback - CI workflow builds on manylinux2014 (glibc 2.17), Alpine, macOS, Windows - prebuilds/ included in npm package files Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@mksglu Please let me know if the test plan is sufficient. |
|
Thanks for this — the approach is technically sound. However, there are two architectural issues we need to resolve before merging: 1. Package size: ship only Linux prebuildsThe glibc/musl mismatch problem is Linux-specific. macOS and Windows users never hit this — better-sqlite3's default prebuild-install works fine there. Shipping 5 platform binaries (~15MB) penalizes all users for a Linux-only problem. Ask: Drop
This cuts package size from ~15MB to ~6MB and targets the actual problem. 2. Publish workflow integrationThe prebuild CI workflow produces artifacts, but there's no path from artifacts → npm package. Currently I publish from local ( This needs a publishing strategy. Options we're considering: A) CI publish (likely direction): Tag push → CI builds prebuilds → CI runs B) Local publish with artifact download: CI builds prebuilds → before publish, a script downloads them from GitHub Actions artifacts → then I need to think through which approach fits our release workflow. Putting this PR on hold until we decide on the publish pipeline — the code itself is ready, it's the delivery mechanism that needs design. Will revisit soon. Thanks for the solid work here. |
|
Hey @Lets7512 — sorry for leaving your test plan question hanging. To answer it directly: yes, the 5 tests in We've decided on the publish pipeline direction — Option A (CI publish). Here's what we need to land this: Changes needed1. Drop macOS and Windows from the prebuild matrix The glibc/musl mismatch is Linux-only. macOS and Windows users are never affected. Please keep only:
2. Wire up CI publish on tag push Add a publish job to the workflow that triggers on
The Once these two changes are in, this is ready to merge. The code in |
The glibc/musl mismatch is Linux-only — macOS and Windows users are unaffected. Ship only linux-x64 and linux-x64-musl prebuilds to cut package size. Add publish job triggered on v* tags using NPM_TOKEN. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hey @mksglu, @flightlesstux — I've addressed both requested changes: 1. Dropped macOS and Windows from the prebuild matrix 2. Added CI publish job on |
|
Hey @Lets7512, thanks for the effort on this — you identified a real problem and took the time to build a solution. I appreciate that. After deep research, we've gone with a documentation-first approach instead. Here's what we found: better-sqlite3 already handles this automatically. Its install script is Alpine is already solved. better-sqlite3 v12.8.0 ships musl prebuilds ( CentOS/RHEL just needs build tools. The auto-fallback triggers, and compiling from source works with GCC 10+ (devtoolset-10 / gcc-toolset-10) and Python setuptools. We've verified the exact commands on CentOS 7 (glibc 2.17), CentOS 8 (glibc 2.28), and Alpine. We've added a Build Prerequisites section to the README on the This avoids the version coupling risk (semver range + fixed prebuilt binary = potential ABI mismatch) and the ~6MB binary bloat from vendoring. Thanks again for flagging this — the documentation wouldn't exist without your PR. 🙏 |
Summary
Ships pre-compiled
better_sqlite3.nodebinaries sonpm install context-modeworks on CentOS 7/8, Alpine, and systems where the default prebuild-install binaries fail due to glibc mismatch.This is an alternative to the sql.js WASM fallback approach in #77. Instead of replacing the database engine, we ship platform-native prebuilds compiled against old glibc (2.17) that work everywhere.
How it works
.nodefiles are shipped inprebuilds/{platform}-{arch}/inside the npm packageSQLiteBasetries the default native binding firstnativeBindingconstructor optionNo extra dependencies. No postinstall scripts. No
binding.gyp. Just better-sqlite3's built-innativeBindingAPI.Platforms
Changes
findPrebuildPath()+ fallback inSQLiteBaseconstructor using better-sqlite3'snativeBindingoptionprebuildsto files arrayTest plan