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

Docker compose suggestion to map /opt/app/ui/.next/cache to ./cache #932

Closed
toddsunpark opened this issue Feb 25, 2024 · 4 comments · Fixed by #1102
Closed

Docker compose suggestion to map /opt/app/ui/.next/cache to ./cache #932

toddsunpark opened this issue Feb 25, 2024 · 4 comments · Fixed by #1102

Comments

@toddsunpark
Copy link

I was getting permission denied errors when the app was trying to write to /opt/app/ui/.next/cache. The directory didn't exist and once I mapped it back I was good to go.

@jorenn92
Copy link
Owner

Are you using a different user than 1000:1000? I've had some reports where this directory wasn't writable when using a different user.

I believe it would be better to change the default Nextjs config, so the cache folder is in a different (writable by all) place altogether.

@toddsunpark
Copy link
Author

toddsunpark commented Feb 27, 2024

Yes! I'm running this on an unRAID server so my default user has to be 99:100. I like your solution better. Just a thought though if you aren't writing cache to a persistent volume don't you lose it every time you move/update your docker container. Unless you meant to move it somewhere in the /opt/data folder.

@KetchupBomb
Copy link

I'm noticing this error message on my end as well when it comes to creating the directory /opt/app/ui/.next/cache:

 ⨯ Failed to write image to cache LEDIQ0xbkbu0XCt3GWtQG5OM0wpjsS8soVFxWoTIvpg= [Error: EACCES: permission denied, mkdir '/opt/app/ui/.next/cache'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/opt/app/ui/.next/cache'
}

I run via Docker Compose with the following relevant spec:

{
  "container_name": "maintainerr",
  "image": "jorenn92/maintainerr",
  "restart": "unless-stopped",
  "user": "65534:65534",  # nobody:nogroup
  "volumes": [
    "/docker/servarr/maintainerr/data:/opt/data"
  ]
}

The host path is owned correctly:

$ ls -alh /docker/servarr/maintainerr/data/
total 80K
drwxr-xr-x 3 nobody nogroup 4.0K May 20 16:00 .
drwxr-xr-x 3 nobody nogroup 4.0K Jan 19 21:24 ..
drwxr-xr-x 2 nobody nogroup 4.0K May 20 00:00 logs
-rw-r--r-- 1 nobody nogroup  68K May 20 16:00 maintainerr.sqlite

And it shows up in the container owned correctly:

$ ls -alh /opt/data/
total 84K    
drwxr-xr-x    3 nobody   nobody      4.0K May 20 23:00 .
drwxrwxrwx    1 node     node        4.0K Mar 25 14:45 ..
drwxr-xr-x    2 nobody   nobody      4.0K May 20 07:00 logs
-rw-r--r--    1 nobody   nobody     68.0K May 20 23:00 maintainerr.sqlite

But the path /opt/app/ is not part of the volume mount, and /opt/app/ui/.next/ is all owned by node, user 1000:

$ id node
uid=1000(node) gid=1000(node) groups=1000(node),1000(node)

$ ls -alh /opt/app/ui/.next/
total 60K    
drwxr-xr-x    1 node     node        4.0K May 21 05:01 .
drwxr-xr-x    1 node     node        4.0K Mar 25 14:44 ..
-rwxr-xr-x    1 node     node          21 Mar 25 14:44 BUILD_ID
-rwxr-xr-x    1 node     node        4.5K Mar 25 14:44 build-manifest.json
-rwxr-xr-x    1 node     node          20 Mar 25 14:44 package.json
-rwxr-xr-x    1 node     node         362 Mar 25 14:44 prerender-manifest.js
-rwxr-xr-x    1 node     node         312 Mar 25 14:44 prerender-manifest.json
-rwxr-xr-x    1 node     node           2 Mar 25 14:44 react-loadable-manifest.json
-rwxr-xr-x    1 node     node        4.5K Mar 25 14:44 required-server-files.json
-rwxr-xr-x    1 node     node        2.3K Mar 25 14:44 routes-manifest.json
drwxr-xr-x    4 node     node        4.0K Mar 25 14:44 server
drwxr-xr-x    6 node     node        4.0K Mar 25 14:43 static

Just wanting to give more information about the issue.

@jorenn92
Copy link
Owner

I'm noticing this error message on my end as well when it comes to creating the directory /opt/app/ui/.next/cache:

 ⨯ Failed to write image to cache LEDIQ0xbkbu0XCt3GWtQG5OM0wpjsS8soVFxWoTIvpg= [Error: EACCES: permission denied, mkdir '/opt/app/ui/.next/cache'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/opt/app/ui/.next/cache'
}

I run via Docker Compose with the following relevant spec:

{
  "container_name": "maintainerr",
  "image": "jorenn92/maintainerr",
  "restart": "unless-stopped",
  "user": "65534:65534",  # nobody:nogroup
  "volumes": [
    "/docker/servarr/maintainerr/data:/opt/data"
  ]
}

The host path is owned correctly:

$ ls -alh /docker/servarr/maintainerr/data/
total 80K
drwxr-xr-x 3 nobody nogroup 4.0K May 20 16:00 .
drwxr-xr-x 3 nobody nogroup 4.0K Jan 19 21:24 ..
drwxr-xr-x 2 nobody nogroup 4.0K May 20 00:00 logs
-rw-r--r-- 1 nobody nogroup  68K May 20 16:00 maintainerr.sqlite

And it shows up in the container owned correctly:

$ ls -alh /opt/data/
total 84K    
drwxr-xr-x    3 nobody   nobody      4.0K May 20 23:00 .
drwxrwxrwx    1 node     node        4.0K Mar 25 14:45 ..
drwxr-xr-x    2 nobody   nobody      4.0K May 20 07:00 logs
-rw-r--r--    1 nobody   nobody     68.0K May 20 23:00 maintainerr.sqlite

But the path /opt/app/ is not part of the volume mount, and /opt/app/ui/.next/ is all owned by node, user 1000:

$ id node
uid=1000(node) gid=1000(node) groups=1000(node),1000(node)

$ ls -alh /opt/app/ui/.next/
total 60K    
drwxr-xr-x    1 node     node        4.0K May 21 05:01 .
drwxr-xr-x    1 node     node        4.0K Mar 25 14:44 ..
-rwxr-xr-x    1 node     node          21 Mar 25 14:44 BUILD_ID
-rwxr-xr-x    1 node     node        4.5K Mar 25 14:44 build-manifest.json
-rwxr-xr-x    1 node     node          20 Mar 25 14:44 package.json
-rwxr-xr-x    1 node     node         362 Mar 25 14:44 prerender-manifest.js
-rwxr-xr-x    1 node     node         312 Mar 25 14:44 prerender-manifest.json
-rwxr-xr-x    1 node     node           2 Mar 25 14:44 react-loadable-manifest.json
-rwxr-xr-x    1 node     node        4.5K Mar 25 14:44 required-server-files.json
-rwxr-xr-x    1 node     node        2.3K Mar 25 14:44 routes-manifest.json
drwxr-xr-x    4 node     node        4.0K Mar 25 14:44 server
drwxr-xr-x    6 node     node        4.0K Mar 25 14:43 static

Just wanting to give more information about the issue.

Thank you for the detailed information! This makes it a lot clearer.

@toddsunpark, the Next.js cache doesn't need to be persistent. It's something Next.js will rebuild after a reboot.

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 a pull request may close this issue.

3 participants