ahdinosaur / ssb-pub

easily host your own Secure ScuttleButt (SSB) pub in a docker container
http://butt.nz/
GNU Affero General Public License v3.0
158 stars 25 forks source link

Image continues restarting when old secret was copied into ssb-pub-data #23

Closed Abekonge closed 5 years ago

Abekonge commented 5 years ago

using docker logs --tail 50 --follow --timestamps sbot to see what was going on inside the container I got the following error:

2019-05-23T19:36:50.831066939Z Error: EEXIST: file already exists, open '/home/node/.ssb/secret'
2019-05-23T19:36:50.831072476Z     at Object.fs.openSync (fs.js:646:18)
2019-05-23T19:36:50.831077713Z     at Object.fs.writeFileSync (fs.js:1299:33)
2019-05-23T19:36:50.831082928Z     at Object.exports.createSync (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-keys/storage.js:104:8)
2019-05-23T19:36:50.831112140Z     at Object.exports.loadOrCreateSync (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-keys/index.js:89:20)
2019-05-23T19:36:50.831118765Z     at setDefaults (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-config/defaults.js:78:27)
2019-05-23T19:36:50.831124436Z     at module.exports (/home/node/.npm-global/lib/node_modules/ssb-server/node_modules/ssb-config/inject.js:7:16)
2019-05-23T19:36:50.831130006Z     at Object.<anonymous> (/home/node/.npm-global/lib/node_modules/ssb-server/bin.js:25:14)
2019-05-23T19:36:50.831135832Z     at Module._compile (module.js:653:30)
2019-05-23T19:36:50.831141105Z     at Object.Module._extensions..js (module.js:664:10)
2019-05-23T19:36:50.831150566Z     at Module.load (module.js:566:32)
2019-05-23T19:37:17.500758652Z fs.js:646
2019-05-23T19:37:17.500814845Z   return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
2019-05-23T19:37:17.500822129Z                  ^
2019-05-23T19:37:17.500827657Z

I removed the secret (and the gossip.json) and tried again, and voila - it worked!

ahdinosaur commented 5 years ago

hmm.. is this because of a file ownership / permissions problem?

can you ls -lh ssb-pub-data when it's working?

if you copy in an old secret, you need to have the ownership / permissions match this, most likely you need to chown 1000:1000 ssb-pub-data/secret to have it owned by the node user in the Docker container.

does that help?

Abekonge commented 5 years ago

Ah good point, forgot to think about that. The copied secret did indeed have the wrong permissions.

So when I chown -R 1000:1000 ~/ssb-pub-data and then afterwards copy in my old secret - there will be an ownership problem.

The readme could point this put, but maybe that would be going into too much detail...

Something like

rsync -avz ~/ssb-pub-data/blobs/sha256/ $HOST:~/ssb-pub-data/blobs/sha256/
# Remember to set the permissions on the newly copied files
chown -R 1000:1000 ~/ssb-pub-data
Abekonge commented 5 years ago

interesting how 1000:1000 sets the permissions to the "first system user", so its my user on the host, and the node user on the container ... clever use of that! but still wondering how docker manages this - what if I copied a file with the second user on the host - what would that become in the container ? anywho I digress ...

ahdinosaur commented 5 years ago

The readme could point this put, but maybe that would be going into too much detail...

yes, happy if you want to submit a pull request! :smiley_cat:

interesting how 1000:1000 sets the permissions to the "first system user", so its my user on the host, and the node user on the container ... clever use of that! but still wondering how docker manages this - what if I copied a file with the second user on the host - what would that become in the container ? anywho I digress ...

1000 is the user id (uid). this number happens to be the "first system user". but the node user in the container is always uid 1000, so if you had a file owned by the second user (e.g. 1001), it won't be owned by the node user because it's not 1000.

ahdinosaur commented 5 years ago

closing because this is resolved, but yeah happy for any pull requests