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