add ZERO_SKIP_SQLITE3_BUILD env to skip native builds #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
Adds an environment variable to skip the native module build during installation. This is killing us in Docker builds for our monorepo where the postinstall script adds ~2 minutes to every build even when the binaries are already cached.
The issue is that
@rocicorp/zero-sqlite3
is intrustedDependencies
in ourbun.lock
(transitive from@rocicorp/zero
which is a devDependency). Even though we don't need it in production, Bun auto-installs it because it's marked as trusted. We can't dynamically remove it fromtrustedDependencies
because Bun's lock file has integrity checks.Right now we're surgically modifying the lock file with
sed
which works but feels hacky.With this change we can just set
ZERO_SKIP_SQLITE3_BUILD=true
in our Dockerfile and skip the unnecessary rebuild.Implementation
install.js
that checks for the env varZERO_SKIP_SQLITE3_BUILD=true
, logs a message and exitsprebuild-install || node-gyp rebuild
flowOur Monorepo Context
In our monorepo:
@rocicorp/zero
is a devDependency inpackages/zero/package.json
@rocicorp/zero-sqlite3
is intrustedDependencies
(transitive dependency)--production
flagCurrent workaround in our Dockerfile:
With this PR:
Testing
Tested on macOS (M1 Mac) with the following results:
Normal Install (no env variable)
With Skip Environment Variable
Performance Impact
On a Mac M1:
In our Docker builds (Linux ARM64 on AWS):
Things to Test
ZERO_SKIP_SQLITE3_BUILD=true