Repository navigation
selfhost: own .next by node so runtime caches are writable - #45
Merged
codewarnab merged 1 commit intoNov 22, 2026
Merged
Conversation
The runtime stage copied /app/.next as root, but the container runs as node. Next writes .next/server/route-cache and the image caches under .next/cache at request time, so every prerender-cache update failed with EACCES and the cache was never written. Use COPY --chown=node:node rather than a recursive chown, which would rewrite the whole tree into another layer.
Contributor
|
@xenon134 is attempting to deploy a commit to the Paws Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
Thanks for finding this and for the clear write-up. Using --chown on the COPY is the right fix, since it avoids an extra layer from chown -R. Merging now. |
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
Running the self-host image as documented produces this on every prerender-cache update:
The message repeats on each request. The prerender cache is never written.
Cause
deploy/selfhost/Dockerfilecopies the build output without changing ownership:COPY --from=build /app/.next ./.nextso the tree arrives as
root:root, while the runtime stage ends withUSER node. Theexisting chown only covers the writable volumes:
RUN mkdir -p /gh .data && chown node:node /gh .dataNext writes
server/route-cacheand the image-optimizer caches undercache/at requesttime, so
nodecannot create them.Fix
COPY --chown=node:node --from=build /app/.next ./.next--chownon the copy avoids adding a recursivechown -Rstep, which would rewrite theentire tree into another image layer.
Verification
ls -ld /app/.nextin the published image reportsroot root, while the process runs asnode.EACCESonmkdir '/app/.next/server/route-cache'.This does not change behaviour of the hosted deployment; it only affects the self-host image.