fix: writable sqlite cache dir (prod EACCES on /build) - #6
Merged
Conversation
The prod image runs as USER node, but WORKDIR /app is root-owned, so the relative default INDEXER_DATA_DIR (./.builder-data = /app/.builder-data) can't be created — every DB-touching route (e.g. creating a project from /build) 500s with `EACCES: permission denied, mkdir './.builder-data'`. The sqlite file is a non-authoritative convenience cache (the pod is the source of truth), so don't let a non-writable dir crash the app: - getDb() now catches a failed open and falls back to os.tmpdir(). - Dockerfile pre-creates /app/.builder-data owned by node (as root, before the USER switch) and sets INDEXER_DATA_DIR to it for a deterministic writable path in prod. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
/build→ "build something new" 500s in prod withEACCES: permission denied, mkdir './.builder-data'.The runtime image runs as
USER node, butWORKDIR /appis root-owned, so the relative defaultINDEXER_DATA_DIR(./.builder-data=/app/.builder-data) can't be created bynode. Every DB-touching route (creating a project) crashes.Fix
The sqlite file is a non-authoritative cache (the pod is the source of truth), so a non-writable dir shouldn't take down the app:
getDb()catches a failed open and falls back toos.tmpdir()/builder-datawith a warning.Dockerfilepre-creates/app/.builder-dataowned bynode(as root, before theUSERswitch) and setsINDEXER_DATA_DIRto it — deterministic writable path in prod.No dev behavior change (still
./.builder-data).tsc --noEmitclean; fallback path verified locally.🤖 Generated with Claude Code