[FEATURE_REQUEST] Allow to mount dist/ directory as volume
jecnua opened this issue · comments
Is your feature request related to a problem? If so, please describe.
Context: Dashy running in docker inside k8s
Currently on a new boot the application takes some time (depending on the CPU available to the pod) to generate the content of the dist/
directory. This process in my case is pretty slow (running on my raspberry PI with low k8s limits).
This per-se would not be a problem if I could cache it, which I was planning to do.
However, when you try to mount a volume in /dist
the boot fails because for some reasons the app tries to delete
the directory before generating it. This is not possible for mounted volumes.
Describe the solution you'd like
I know close to nothing about how vue works but I found a way to hack it temporarily (in my case). By adding to the build
script the flag --no-clean
I am able to start up the pod correctly and make it generate the files.
I do this by mounting a "modified" version of the package.json inside the container at runtime, but I expect I could achieve the same by sed-ding the line at startup via init-container.
I don't understand the reason to delete the dir itself, when would be enough to clean the content of it, however I expect this to be an intrinsic behaviour of the framework.
It would be good to have a way to allow the app to "not" try to delete the directory at startup and allow the cache directory to be mounted as volume from outside for systems with small resourses to spare in asset generation.
Priority
Medium (Would be very useful)
Is this something you would be keen to implement
None
Hi @Lissy93 , thank you for the quick reply and taking this on.
I saw the commit, but please correct me if I am wrong (I know nothing of nodejs/yarn/etc), but isn't the issue that docker command is:
Thank build-and-start
calls build
:
https://github.com/Lissy93/dashy/blob/master/package.json#L14
and that build
is missing the flag --no-clean
?
https://github.com/Lissy93/dashy/blob/master/package.json#L10
Even if you change the dockerfile the build call above will (try to) remove the directory at runtime?
Basically I tried this change locally (adding a couple of yarn scripts in the package.json):
And if they are there, in k8s I can override the command and call the no-clean option:
command:
- yarn
- build-no-clean-and-start
I am not doing the PR because I understand the change is horrible, and I don't expect to pollute the repo with every single user usecase ^^ But maybe the example can help finding a cleaner solution to allow the no-clean option?
Ah yes, you're right, it should go in the run stage, and not the build stage - so the package.json under build-and-start
command would work
Yeah, it should. I'll do it when I get a moment, it's not merged yet, so it's chill
I will close this issue since I have a temporary workaround for now.