Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Permission Denied error when running on Docker #31

Merged

Conversation

ChubaOraka
Copy link
Collaborator

Fixes #30

Turns out the volume mounts are done as root. I chowned the .next and node_modules folders and this fixes the problem.

@ChubaOraka ChubaOraka force-pushed the fix-docker-permission-denied-error branch from 547cd64 to d96f6a0 Compare August 22, 2022 16:39
…tainer's default non-root user `node`

Error Log:
client    | [Error: EACCES: permission denied, open '/usr/src/app/client/.next/package.json'] {
client    |   errno: -13,
client    |   code: 'EACCES',
client    |   syscall: 'open',
client    |   path: '/usr/src/app/client/.next/package.json'
client    | }

References:
node.js - How to keep node_modules inside container while using docker-compose and a non-root user? - Stack Overflow
https://stackoverflow.com/questions/49941708/how-to-keep-node-modules-inside-container-while-using-docker-compose-and-a-non-r
https://stackoverflow.com/a/49952703
https://stackoverflow.com/questions/49941708/how-to-keep-node-modules-inside-container-while-using-docker-compose-and-a-non-r/49952703#49952703

Docker Compose mounts named volumes as 'root' exclusively · Issue #3270 · docker/compose · GitHub
docker/compose#3270

Stuck with a Problem of access permission denied · Issue #8908 · vercel/next.js · GitHub
vercel/next.js#8908
vercel/next.js#8908 (comment)

What is the best way to use NextJS with docker? · Discussion #16995 · vercel/next.js · GitHub
vercel/next.js#16995

reactjs - error An unexpected error occurred: "EACCES: permission denied - Stack Overflow
https://stackoverflow.com/questions/52713928/error-an-unexpected-error-occurred-eacces-permission-denied

docker - Dockerfile with nextjs and puppteer permission denied - Stack Overflow
https://stackoverflow.com/questions/64565062/dockerfile-with-nextjs-and-puppteer-permission-denied
[RUN chown -Rh $user:$user /home/node]
https://stackoverflow.com/a/64922590
https://stackoverflow.com/questions/64565062/dockerfile-with-nextjs-and-puppteer-permission-denied/64922590#64922590
[More relevant for production build, suggests we modify next.config.js by adding a distDir directive:
module.exports = {
      distDir: 'build',
      serverRuntimeConfig: {
        // Will only be available on the server side
        apiUrl: 'http://signup-api:1984'
      },
      publicRuntimeConfig: {
        // Will be available on both server and client
        apiUrl: 'http://localhost:1984'
      }
    }
]
@ChubaOraka ChubaOraka force-pushed the fix-docker-permission-denied-error branch from d96f6a0 to e9e8216 Compare August 22, 2022 17:17
@simplytunde simplytunde self-requested a review August 23, 2022 03:40
@simplytunde simplytunde merged commit d9e3b48 into KanaryStack:main Aug 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix Permission Denied error when running on Docker
2 participants