From 49a891deb59be06b666aec0c3cddf33bf3d24824 Mon Sep 17 00:00:00 2001 From: Rui Ying Date: Fri, 1 Sep 2023 10:19:13 -0700 Subject: [PATCH] Fix the prerender cache update error with the example Dockerfile (#54870) It seems the app router attempts to write its cache to both `.next/cache` and `.next/server` in docker. This fix should fix standalone output server's error `Failed to update prerender cache... [Error: EACCES: permission denied...` when deployed in a docker container with the example Dockerfile. Related discussion: https://github.com/vercel/next.js/discussions/51164 --- examples/with-docker/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/with-docker/Dockerfile b/examples/with-docker/Dockerfile index 791eff1edbecd..28514819179b9 100644 --- a/examples/with-docker/Dockerfile +++ b/examples/with-docker/Dockerfile @@ -45,6 +45,10 @@ RUN adduser --system --uid 1001 nextjs COPY --from=builder /app/public ./public +# Set the correct permission for prerender cache +RUN mkdir .next +RUN chown nextjs:nodejs .next + # Automatically leverage output traces to reduce image size # https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./