umbrel-apps icon indicating copy to clipboard operation
umbrel-apps copied to clipboard

nutstash version 0.1.12

Open gandlafbtc opened this issue 1 year ago • 3 comments

I'm trying to introduce a feature to sync tokens with the umbrel server. It's still not completely working. I think the issue is that i need write access to the host system to have a persistent volume.

The rest should work fine, but I would like to fix that before merging the new version.

Maybe you guys have a good idea how to solve this @nmfretz ? I'm pretty dumb at docker

gandlafbtc avatar May 23 '23 06:05 gandlafbtc

Sorry for the delay @gandlafbtc. I'll take a look at this tomorrow so we can get this update out the door!

I too used to be pretty dumb at docker. Now I am only fairly dumb at docker.

nmfretz avatar Jun 06 '23 06:06 nmfretz

@gandlafbtc I've pushed some changes that should get us closer on the Umbrel-integration end of things:

  • Updated the volume bind mount to a single directory on both the host and web container, instead of binding the actual .json files: ${APP_DATA_DIR}/data/backup:/etc/nutstash
    • This eliminates the need for default .json files in the repo and avoids the issue where Docker creates an empty directory in the container if the specified file doesn't exist on the host.
    • If the tokens.json and mints.json files are stored in the web container at a path other than etc/nutstash, then you can change this side of the bind mount to whatever path is relevant.
  • Created folders in this repo for the backup directory on the host: ${APP_DATA_DIR}/data/backup
  • Added a pre-start script that creates the new host data folders (${APP_DATA_DIR}/data/backup) for existing nutstash users updating their app.
    • This is needed because Umbrel only copies all files from the app's repo during installation, not during updates (to preserve users' custom configs). During update it only copies over a whitelist of files (https://github.com/getumbrel/umbrel/commit/73f99fa7ac930c905cc16d08336edd7dfdd7afcf#diff-8e674b8e14b37a67c77e07bc9ad10ace548b82c5729fe2c679001b6eedd4dd41R547-R553). The script ensures that users updating their existing app receive these new folders.

Next steps

Here's some notes to help us make any necessary changes to nutstash to get things working. Apologies in advance if I send us down the wrong path a bit while trying to understand how nutstash works.

tokens.json & mints.json paths

How does nutstash handle the creation of the backup .json files? Are they created only when a user selects Sync tokens to server in settings? When I navigate to etc/nutstash inside the web container I don't see either .json file even after I have added a mint and tokens, selected the sync function, and restarted the app:

$ sudo docker exec -it nutstash-wallet_web_1 sh
/app $ cd ../etc/nutstash/
/etc/nutstash $ ls -l
total 0

It actually looks like /etc/nutstash isn't created until the sync function is selected and the app restarted, which may cause issues.

The nutstash web container spits out these errors related to the backup files:

[Error: EACCES: permission denied, open './tokens.json'] {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: './tokens.json'
}
[Error: ENOENT: no such file or directory, open '/app/data/tokens.json'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/app/data/tokens.json'
}

The path associated with these errors is not /etc/nutstash where I was expecting the .json backups to be stored. Is that intentional?

One solution here may be to have nutstash check for .json backup files on startup, and create default empty JSONs if the files do not exist. If a user's json files exist on the host machine and you use a bind mount in the Docker setup, the specified files will be accessible within the container.

restarting the app

Right now, there is no easy way for a user to restart a single app from Umbrel's UI. This feature is on the roadmap, but for now a user either has to either restart their entire Umbrel from the dashboard or else SSH into their umbrel and run a command to restart nutstash (sudo ~/umbrel/scripts/app restart nutstash-wallet). Is there an easy way you can have it so that an app restart is not required when you toggle Sync to server?

nmfretz avatar Jun 07 '23 21:06 nmfretz

Thanks for your work on this! I have had some other things pending, but I will work on this again next week. I will dive into it on monday. Also sorry for the delayed reply on my side.

I have just skimmed through your comments, but i think this helps a ton, and im fairly certain we can push the update out before next weekend. Then I can also include all the latest features with the next update.

I will look into options for avoiding the need for an app restart.

gandlafbtc avatar Jun 16 '23 07:06 gandlafbtc

Hey @gandlafbtc, are you okay if I close this old draft PR? We can reopen down the line if you get back to working on it at some point.

nmfretz avatar Aug 29 '24 00:08 nmfretz

@gandlafbtc I see nutstash is now on v0.2.7 https://github.com/gandlafbtc/nutstash-wallet/releases/tag/0.2.7

Let's close this old 0.1.12 PR. Please ping me whenever you're ready for an update 🌰

nmfretz avatar Sep 03 '24 23:09 nmfretz