fix(docker): pin prisma caches to a UID-independent path so air-gapped and arbitrary-UID deploys work - #33700
Conversation
…d and arbitrary-UID deploys work
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Greptile SummaryThis PR fixes Prisma cache resolution for arbitrary-UID and air-gapped container deployments by pinning the cache to a fixed, UID-independent path (
Confidence Score: 5/5Safe to merge — the change is confined to Dockerfile build instructions, is verified end-to-end by the author in an air-gapped, arbitrary-UID environment, and is consistent with the approach already used in the non-root image variant. Both Dockerfiles apply the fix symmetrically and correctly: the ENV vars are set before prisma generate in the builder stage so the cache is written to the right path, the full cache directory is then copied to the runtime stage, and chmod -R a+rX ensures readability under any UID. The /opt/prisma-cache path deliberately avoids the /app/.cache emptyDir shadowing trap that was already documented in the prior comment block. No application code is touched. No files require special attention.
|
| Filename | Overview |
|---|---|
| Dockerfile | Sets XDG_CACHE_HOME and PRISMA_BINARY_CACHE_DIR to /opt/prisma-cache in both builder and runtime stages, copies the cache from builder, and applies a+rX permissions — correctly addressing the UID-independent path requirement. |
| docker/Dockerfile.database | Identical fix to Dockerfile: pins Prisma caches to /opt/prisma-cache in both stages; no divergence from the main Dockerfile's approach. |
Reviews (1): Last reviewed commit: "fix(docker): pin prisma caches to a UID-..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Closing this in favor of #33853, which shipped an equivalent fix (baking the prisma CLI and engines at a fixed /opt path so migrations run for any uid offline) and has already merged and been backported to the stable 1.90.x and 1.91.x lines. #34325 followed up with the non_root variant. The default branch now resolves the prisma cache at /opt/prisma independent of $HOME, which is what this PR was after, so there is nothing left here to add. Thanks to the folks who landed those |
Relevant issues
Fixes #33365
Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaito re-request a review after pushing changes). Scored 5/5Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Repro environment:
docker network create --internal airgap(containers can reach each other, zero egress), postgres:16-alpine on it, and the litellm image withDATABASE_URLset and a minimal config.--user 12345:12345simulates a Kubernetes arbitrary-UID securityContextPublished image (
ghcr.io/berriai/litellm:main-latest), arbitrary UID, air-gapped:Same image built with this PR, same command, arbitrary UID, air-gapped:
Root regression check (patched image, default user, air-gapped): migrations complete and the proxy serves identically. The remote model-cost-map fetch logs a warning and falls back to the local backup, which is the expected offline behavior
Type
🐛 Bug Fix
Changes
Prisma resolves every cache location relative to $HOME: the python client looks for engines in
~/.cache/prisma-python/binaries/<version>/<hash>and the node CLI keeps its engines in~/.cache/prisma. The published root images bake these caches into/root/.cacheand rely on the process running as root with HOME=/root. Kubernetes deployments that set an arbitrary runAsUser (standard pod hardening, and the default on OpenShift) get HOME=/ instead, so prisma misses the baked caches, tries to mkdir/.cacheand re-download the toolchain, and the pod dies; in an air-gapped cluster the download can never succeed, which is the failure in #33365 (and earlier #4915). The same $HOME dependence is why the reporter's traceback shows nodeenv downloading Node into/.cache/prisma-python/nodeenvThe fix pins the caches to a fixed, UID-independent path at build time and runtime: XDG_CACHE_HOME and PRISMA_BINARY_CACHE_DIR are set to
/opt/prisma-cachein both stages of Dockerfile and docker/Dockerfile.database,prisma generatein the builder populates that path, the runtime stage copies it and makes it world-readable (a+rX)./optis used rather than/app/.cachedeliberately: deployments with readOnlyRootFilesystem mount an emptyDir over/app/.cache, which would shadow baked-in engines (the old comment in Dockerfile.database documents that trap). The non_root image already ships equivalent env pinning; this brings the two root images in lineNo application code changes. Runtime behavior for existing root deployments is unchanged (verified below); arbitrary-UID and air-gapped deployments go from crash-looping to serving
QA runbook
docker network create --internal airgapand start postgres on it--user 12345:12345, DATABASE_URL pointing at the postgres, and any minimal configPermissionError: [Errno 13] Permission denied: '/.cache'after failing to find/.cache/prisma-python/binaries/...; after it, migrations run and the proxy serves on :4000 with no egress--user(root) to confirm the default path still worksFinal Attestation