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

[FEATURE_REQUEST] Allow to mount dist/ directory as volume #1570

Closed
jecnua opened this issue May 6, 2024 · 7 comments
Closed

[FEATURE_REQUEST] Allow to mount dist/ directory as volume #1570

jecnua opened this issue May 6, 2024 · 7 comments
Labels
🦄 Feature Request [ISSUE] Suggestion for new feature, update or change

Comments

@jecnua
Copy link

jecnua commented May 6, 2024

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

@jecnua jecnua added the 🦄 Feature Request [ISSUE] Suggestion for new feature, update or change label May 6, 2024
@Lissy93
Copy link
Owner

Lissy93 commented May 11, 2024

I believe this should be possible by modifying the build command, to include the --no-clean flag [docs]

dashy/Dockerfile

Lines 24 to 25 in eea193a

# Build initial app for production
RUN yarn build --mode production

- RUN yarn build --mode production
+ RUN yarn build --mode production --no-clean

I'll test that out this evening, and see if I can get a PR for you :)

@jecnua
Copy link
Author

jecnua commented May 11, 2024

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:

build-and-start

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?

@liss-bot liss-bot added the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 11, 2024
@jecnua
Copy link
Author

jecnua commented May 11, 2024

Basically I tried this change locally (adding a couple of yarn scripts in the package.json):

https://github.com/Lissy93/dashy/compare/master...jecnua:dashy:1570-add-build-no-clean-option?expand=1

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?

@Lissy93
Copy link
Owner

Lissy93 commented May 11, 2024

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

@liss-bot liss-bot removed the 👤 Awaiting Maintainer Response [ISSUE] Response from repo author is pending label May 11, 2024
@CrazyWolf13

This comment was marked as off-topic.

@Lissy93
Copy link
Owner

Lissy93 commented May 13, 2024

Yeah, it should. I'll do it when I get a moment, it's not merged yet, so it's chill

@jecnua
Copy link
Author

jecnua commented May 22, 2024

I will close this issue since I have a temporary workaround for now.

@jecnua jecnua closed this as completed May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🦄 Feature Request [ISSUE] Suggestion for new feature, update or change
Projects
None yet
Development

No branches or pull requests

4 participants