NextJS cannot save to cache on fly.io

I’m getting the following NextJS error (using the default dockerfile, except Node 20 instead of Node 18).

2023-05-09T06:19:34Z app[e784ee62f61483] bos [info]Failed to update tags manifest. [Error: EACCES: permission denied, mkdir '/app/.next/cache/fetch-cache'] {
2023-05-09T06:19:34Z app[e784ee62f61483] bos [info]  errno: -13,
2023-05-09T06:19:34Z app[e784ee62f61483] bos [info]  code: 'EACCES',
2023-05-09T06:19:34Z app[e784ee62f61483] bos [info]  syscall: 'mkdir',
2023-05-09T06:19:34Z app[e784ee62f61483] bos [info]  path: '/app/.next/cache/fetch-cache'
2023-05-09T06:19:34Z app[e784ee62f61483] bos [info]}

Assuming that dockerfile contains the following lines:

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app ./

USER nextjs

If so, add a line like the following after the COPY line:

RUN chown -R nextjs:nodejs /app/.next/cache

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.