dockerizing nextjs [Error: EACCES: permission denied, mkdir
Unanswered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
i am dockerizing my nextjs (14.1.4) application and ship it on a openshift cluster.
I used the provided example:
https://github.com/vercel/next.js/tree/canary/examples/with-docker
I found a similar discussion on github:
https://github.com/vercel/next.js/discussions/51164
The error msg i face is this:
Failed to update prerender cache for b27af8bd4ffd389d185bc5388917d31263281af11ca86bd0c14fe5f73342cb7d [Error: EACCES: permission denied, mkdir '/app/.next/cache'] {
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/app/.next/cache'
}
Does anyone have/had this issue too?
I used the provided example:
https://github.com/vercel/next.js/tree/canary/examples/with-docker
I found a similar discussion on github:
https://github.com/vercel/next.js/discussions/51164
The error msg i face is this:
Failed to update prerender cache for b27af8bd4ffd389d185bc5388917d31263281af11ca86bd0c14fe5f73342cb7d [Error: EACCES: permission denied, mkdir '/app/.next/cache'] {
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/app/.next/cache'
}
Does anyone have/had this issue too?
3 Replies
Dwarf Crocodile
I have made my own dockerfile for nextjs here
It might not be optimal but i solved the errors you're getting by just chmodding the entire directory. This would look like something like this for you:
I put this right before my
FROM node:iron
RUN npm install -g pnpm
WORKDIR /usr/src
RUN git clone https://git.ssis.nu/togethernet/ui.git
WORKDIR /usr/src/ui
RUN pnpm install
WORKDIR /usr/src/app
RUN ls
SHELL ["/bin/bash", "--login", "-c"]
ENV SHELL bash
COPY . .
RUN mkdir -p /.cache/pnpm/dlx
RUN chmod 777 /.cache/pnpm/dlx/ -R
RUN mkdir -p /usr/src/app/.next/cache/fetch-cache
RUN chmod 777 /usr/src/app/.next/cache -R
RUN chmod 777 /usr/src/app -R
RUN chmod 744 ./prisma/schema.prisma
RUN pnpm install
RUN pnpm dlx prisma generate
RUN pnpm build
CMD ["pnpm", "start"]It might not be optimal but i solved the errors you're getting by just chmodding the entire directory. This would look like something like this for you:
RUN chmod 777 /app/.next/cache -RI put this right before my
npm/pnpm installNortheast Congo LionOP
thank you @Dwarf Crocodile that workarround did work
Dwarf Crocodile
np