homarr icon indicating copy to clipboard operation
homarr copied to clipboard

Local resources do not load until container is pulled down and bought up

Open gxgani opened this issue 3 years ago • 8 comments

Environment

Docker

Version

0.7.0

Describe the problem

Mount the ./icons (host) volume onto container as /app/public/icons. Resources return 404 unless the container has been pulled down and loaded again (restarting container does not work)

Additional info

No response

Please tick the boxes

  • [X] You've read the docs
  • [X] You've checked for duplicate issues
  • [X] You've tried to debug yourself

gxgani avatar Jun 13 '22 16:06 gxgani

So you're saying accessing a mounted icon doesn't work automatically ?

ajnart avatar Jun 13 '22 18:06 ajnart

So you're saying accessing a mounted icon doesn't work automatically ?

yes! It returns 404. Using the wiki's docker-compose template. I move an icon into host volume, I see the icon in the container as well but returns 404 unless I pull the container down and up again. (Tried chmod/chown the icon, did not work either)

gxgani avatar Jun 13 '22 18:06 gxgani

So you're saying accessing a mounted icon doesn't work automatically ?

yes! It returns 404. Using the wiki's docker-compose template. I move an icon into host volume, I see the icon in the container as well but returns 404 unless I pull the container down and up again. (Tried chmod/chown the icon, did not work either)

This is a weird scenario. I will do some testing

ajnart avatar Jun 13 '22 18:06 ajnart

So you're saying accessing a mounted icon doesn't work automatically ?

yes! It returns 404. Using the wiki's docker-compose template. I move an icon into host volume, I see the icon in the container as well but returns 404 unless I pull the container down and up again. (Tried chmod/chown the icon, did not work either)

This is a weird scenario. I will do some testing

I experience the same thing and have done some testing as well.

Running just yarn locally, this is not an issue. Icons can be added to /icons/ then loaded into dashboard without restarting yarn.

Running through docker, it can't see the icons until container is restarted. While the container is running, if you remove an icon from /icons/, it will not show up on dashboard anymore, then re-add that same file, it will work again without restarting container. Renaming an existing file will make the file no longer work until container is restarted or it's named back to what it was when the container was started.

You can see by having Dev Console open in browser, when typing in filename it will 404 for the path even if the file exists.

I am using Docker for Windows and if I open a terminal into the container and pwd /app/public/icons/ it can see the new icons, it just won't load on dashboard.

DebugDax avatar Jun 13 '22 20:06 DebugDax

I am running Truenas Scale and having the same problem. Its a weird one. If I shutdown and restart the container, I will then be able to use the icon I can already see. To get past this I just uploaded my whole icon directory and restarted. Its overkill but it worked.

Trodfoot avatar Jun 14 '22 01:06 Trodfoot

This is indeed very annoying and it seems to be a NextJS limitation. I will put this link below describing what I believe could be a fix for this issue

  • making an API route that would try and return the file, with a rewrite to any url that starts with /icons/IMG.png to /api/getIcon/IMG.png https://stackoverflow.com/questions/71618052/how-to-serve-static-file-dynamically-using-next-js

ajnart avatar Jun 14 '22 19:06 ajnart

Found a similiar solution here: https://stackoverflow.com/questions/60799704/images-not-loading-unless-i-rebuild-app-next-js

lammersbjorn avatar Jun 23 '22 09:06 lammersbjorn

Found a similiar solution here: https://stackoverflow.com/questions/60799704/images-not-loading-unless-i-rebuild-app-next-js

Yes but I don't know where to put this code 😅 And do we really need express for just one route? Might be able to just use NextJS rewrites with one API route

Make it so /icons/id goes to /api/getIcon/Id and make the getIcon/[is].ts return the right file if found ?

edit : That's what I wrote previously

ajnart avatar Jun 23 '22 09:06 ajnart